User Rating 0.0
Total Usage 0 times
Drop a file containing Data URI or click to paste Supports .txt, .uri, or any text file
Paste your Data URI starting with data:
Quick examples:
Is this tool helpful?

Your feedback helps us improve.

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.

data-uri xml base64 decoder converter xml-parser data-url

Formulas

A Data URI follows the structure defined in RFC 2397. The parser extracts each component using pattern matching:

datauri = "data:" mediatype params "," data

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:

bytes = n × 34

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:

valid = ¬contains(doc, "parsererror")

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 ComponentFormatExampleRequired
Schemedata:data:Yes
MIME Typetype/subtypeapplication/xmlNo (defaults to text/plain)
Character Set;charset=encoding;charset=utf-8No
Base64 Flag;base64;base64No (if absent, URL-encoded)
Data Separator,,Yes
Payloadencoded-contentPD94bWwgdm...Yes
XML MIME TypeUsageFile Extension
application/xmlGeneric XML documents.xml
text/xmlHuman-readable XML.xml
application/xhtml+xmlXHTML documents.xhtml
image/svg+xmlSVG vector graphics.svg
application/rss+xmlRSS feeds.rss
application/atom+xmlAtom feeds.atom
application/mathml+xmlMathematical markup.mml
application/xslt+xmlXSLT stylesheets.xslt
application/soap+xmlSOAP messages.xml
application/rdf+xmlRDF data.rdf
Base64 CharacterValueBase64 CharacterValue
A-Z0-25a-z26-51
0-952-61+62
/63=Padding
Common XML DeclarationDescription
<?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

Frequently Asked Questions

Base64 requires input length divisible by 4. If the string is truncated, atob() throws an InvalidCharacterError. The tool detects this and reports the expected padding. You can often fix truncation by adding = characters until length mod 4 equals 0. However, the decoded content may still be incomplete if actual data was lost.
Yes. SVG uses the image/svg+xml MIME type and XHTML uses application/xhtml+xml, but both are valid XML. The tool decodes and validates any XML-based format. It detects the MIME type from the Data URI and adjusts the download filename extension accordingly (.svg, .xhtml, .xml).
Data URIs typically store text as UTF-8 regardless of the XML declaration. If your XML declares encoding="UTF-16" but the Data URI contains UTF-8 bytes, parsers may fail. The tool decodes using TextDecoder with UTF-8, then validates the result. If encoding mismatch errors occur, you may need to re-encode the source file before creating the Data URI.
The tool enforces a 10MB limit on the encoded Data URI string to prevent browser memory issues. This corresponds to approximately 7.5MB of decoded binary data (due to Base64's 33% size overhead). For larger files, consider using standard file transfer methods instead of Data URIs.
Common causes include: undeclared namespace prefixes (e.g., using xsi: without declaring xmlns:xsi), unescaped ampersands in text content (use & instead of &), mismatched tag names (XML is case-sensitive), and byte-order marks (BOM) at the start of the file. The error message specifies the line and column where parsing failed.
Yes. If the ;base64 parameter is absent, the tool applies decodeURIComponent() to the payload instead of atob(). This handles percent-encoded characters like %3C for < and %3E for >. Both encoding schemes produce identical XML output when properly decoded.