Data URI to XML Converter
Convert Base64 Data URIs to XML files instantly. Decode, validate, prettify and download XML content embedded in Data URI format.
data:
About
Data URIs embed file content directly into strings using the data:[mediatype][;base64],data scheme defined in RFC 2397. When that embedded payload is XML, extracting it requires decoding the Base64 or percent-encoded content, then validating the result against XML well-formedness rules. Malformed Data URIs or corrupted Base64 sequences produce parsing failures that break downstream integrations. This tool performs the full pipeline: it parses the URI structure, detects the encoding scheme, decodes the payload, validates XML syntax via DOMParser, and optionally prettifies the output with configurable indentation of 2 or 4 spaces.
Common failure modes include truncated Base64 strings (length not divisible by 4), invalid characters in the encoded segment, and XML content with undeclared namespaces or encoding mismatches. The tool reports specific error locations when validation fails, allowing targeted fixes rather than blind debugging. Output can be copied to clipboard or downloaded as an .xml file with proper UTF-8 encoding.
Formulas
A Data URI follows the structure defined in RFC 2397. The parser extracts each component using pattern matching:
Where mediatype defaults to text/plain;charset=US-ASCII if omitted, and params may include ;base64 to indicate Base64 encoding.
Base64 decoding converts each group of 4 characters into 3 bytes:
Where n = number of Base64 characters (excluding padding). The padding character = indicates missing bytes: one = means 2 output bytes, two == means 1 output byte.
XML validation uses DOMParser to check well-formedness. A document is well-formed if:
Where doc is the parsed DOM tree. Parser errors inject a parsererror element which signals malformed XML structure, unclosed tags, or encoding issues.
Reference Data
| Data URI Component | Format | Example | Required |
|---|---|---|---|
| Scheme | data: | data: | Yes |
| MIME Type | type/subtype | application/xml | No (defaults to text/plain) |
| Character Set | ;charset=encoding | ;charset=utf-8 | No |
| Base64 Flag | ;base64 | ;base64 | No (if absent, URL-encoded) |
| Data Separator | , | , | Yes |
| Payload | encoded-content | PD94bWwgdm... | Yes |
| XML MIME Type | Usage | File Extension |
|---|---|---|
| application/xml | Generic XML documents | .xml |
| text/xml | Human-readable XML | .xml |
| application/xhtml+xml | XHTML documents | .xhtml |
| image/svg+xml | SVG vector graphics | .svg |
| application/rss+xml | RSS feeds | .rss |
| application/atom+xml | Atom feeds | .atom |
| application/mathml+xml | Mathematical markup | .mml |
| application/xslt+xml | XSLT stylesheets | .xslt |
| application/soap+xml | SOAP messages | .xml |
| application/rdf+xml | RDF data | .rdf |
| Base64 Character | Value | Base64 Character | Value |
|---|---|---|---|
| A-Z | 0-25 | a-z | 26-51 |
| 0-9 | 52-61 | + | 62 |
| / | 63 | = | Padding |
| Common XML Declaration | Description |
|---|---|
| <?xml version="1.0"?> | Minimal declaration |
| <?xml version="1.0" encoding="UTF-8"?> | With UTF-8 encoding |
| <?xml version="1.0" encoding="UTF-16"?> | With UTF-16 encoding |
| <?xml version="1.0" standalone="yes"?> | Standalone document |
| <?xml version="1.1" encoding="UTF-8"?> | XML 1.1 version |