XML to JSON
Convert an XML document into an ordered JSON tree. Its child arrays show where text, elements and other content appeared.
Convert XML
- Paste one XML document or choose a UTF-8 file.
- Select Pretty or Compact and choose Convert.
- Review the JSON, then copy it or download the file.
Read the JSON tree
Each element has arrays for attributes, local namespace declarations and children. Repeated element names remain separate entries in source order.
Namespace URIs identify expanded names. The default namespace gives unprefixed elements a namespace, while ordinary unprefixed attributes stay unnamespaced.
XML values remain strings. The parser decodes predefined references and applies XML's line ending and attribute normalization.
Examples
The content A<b/> B becomes three entries in order: text, an empty element and text.
An attribute id with value 0007 stays the string 0007. Pretty adds layout whitespace to the JSON without changing the tree.
Supported input
Use one XML 1.0 document up to 2 MiB. The tool declines documents with a DOCTYPE and applies structure and output limits.
This format uses explicit arrays and names. A consumer that expects properties keyed by tag name needs a separate mapping.
Local conversion
The browser processes the document on your device. Namespace and other reference strings remain data, and the converter does not fetch them.
XML conversion questions
Sources
These references describe the XML model used by the converter.
- W3Cw3.orgXML 1.0Defines document syntax, character references and normalization.
- W3Cw3.orgNamespaces in XML 1.0Explains prefixes, default namespaces and expanded names.
- W3Cw3.orgXML Information SetDescribes the items in a parsed XML document and the order of its children.
The JSON field names and representation are specific to this converter.
References reviewed November 18, 2026.
Related tools
JSON to TypeScript
Infer a TypeScript type alias from a JSON sample, then review, copy or download the code.
Open tool — JSON to TypeScriptJSON to YAML
Convert JSON to YAML locally while preserving number text and quoted strings; copy or download the complete result.
Open tool — JSON to YAMLYAML to JSON
Convert one YAML document locally to JSON with exact number text and bounded aliases, then copy or download the complete result.
Open tool — YAML to JSONYAML Formatter
Format YAML indentation and copy the checked result while retaining comments and source details.
Open tool — YAML FormatterXML Formatter
Check namespace-aware XML 1.0, format or compact locally, and copy or download UTF-8 output.
Open tool — XML FormatterJSON Formatter & Validator
Check JSON syntax, format or minify locally, and copy or download output while preserving original data tokens.
Open tool — JSON Formatter & Validator