XML ↔ JSON Converter
Represent XML as ordered JSON nodes, including text interleaved with elements. Attributes live in attributes arrays and child nodes in children arrays, retaining repeated elements and text positions. Only this explicit node model converts back to XML; ordinary business JSON keys are not guessed as tag names.
Key features
- Convert XML to explicit node JSON and back
- Distinguish elements, attributes, text, CDATA, comments and processing instructions
- Keep repeated elements and mixed text in node order
- Validate XML syntax, namespaces and a single root; reject DTD declarations
How to use
- Select XML to JSON and enter a document with one root element.
- Run it and inspect the type, name, attributes and children node fields.
- To restore XML, paste the JSON result into the input and select JSON to XML.
- Copy and compare the content. The result is not guaranteed to match original file bytes.
Use cases
- Inspect XML with emphasis tags and spaces inside sentences
- Transfer repeated XML elements and attributes into ordered JSON
- Create explicit XML structure fixtures and restore them
Frequently asked questions
Can any ordinary JSON object become XML?
Only this tool’s node model is supported. The document has type: document, declaration and children. An element has type: element, name, attributes and children. Convert the XML example first to obtain a valid template.
Are repeated names and spaces between inline tags retained?
The children array retains node order, including repeated sibling elements and intervening text. Text and CDATA are distinguished. XML output does not insert indentation into mixed text.
Will the XML match the original file exactly?
Byte-for-byte equality is not guaranteed. XML parsing may normalize line breaks, entity references and attribute whitespace; quoting and empty-element syntax may also change. This is not XML canonicalization for signatures or hashes.
Are DTD, external entities or XSD supported?
DTD and ENTITY declarations are rejected, and no external file or schema is fetched. XSD validation is not performed. The tool checks XML 1.0 declarations and the document syntax and namespaces supported by the browser parser.
Does XML containing script or style execute?
Input is read as a detached XML document and node data. Its nodes are never inserted into the current page, and output is displayed as text. The tool does not execute input scripts or apply linked styles.
What happens with invalid models or oversized input?
Unknown fields, unsupported node types, duplicate attributes and invalid comment or CDATA content are rejected. Input and generated XML are limited to 100,000 UTF-16 code units, with at most 10,000 nodes and 100 nesting levels.
Privacy
Input and results are processed in browser memory; this tool does not upload or store them. Reloading clears them. Site-wide advertising and analytics may operate separately, but tool usage events do not contain your input or output.
Comments & questions