XML ↔ JSON Converter
Paste XML or JSON and convert in either direction with a clear, consistent mapping. Errors point to the line and column, special characters are escaped correctly, and unsafe XML constructs are rejected. Nothing is uploaded.
Convert
No DTDs · no external entitiesConversion format
- Element → key with the element name:
<title>Hi</title>⇄"title": "Hi" - Attribute → key starting with @:
<book id="1">⇄"@id": "1" - Text next to attributes or child elements →
"#text"(several text runs → array) - Repeated sibling elements → array:
<a>1</a><a>2</a>⇄"a": ["1", "2"] - Empty element ⇄
null; all XML values stay text strings
Comments, processing instructions and the exact position of text in mixed content don’t survive a round trip. DOCTYPE and entity declarations are rejected.
About XML ↔ JSON Converter
XML ↔ JSON Converter converts XML documents to JSON and JSON back to XML using one documented mapping: attributes become “@” keys, text next to attributes or children becomes “#text”, and repeated sibling elements become arrays. XML is parsed by the browser’s XML parser after rejecting DOCTYPE and entity declarations; JSON is parsed by a strict parser with line-and-column errors. Output is formatted and checked before it is shown.
Many systems still exchange XML (feeds, SOAP services, configuration and office formats) while modern APIs and tools prefer JSON. Converting with a predictable mapping makes it easy to move data between them and to inspect XML in JSON-friendly tools, without uploading the data.
Step by step
- Paste XML into the left box or JSON into the right box, or press Load sample.
- Choose the indentation and whether to trim whitespace around XML text.
- Press XML → JSON or JSON → XML.
- If an error appears, read the line and column and use Go to error.
- Review any notes about dropped comments or mixed content.
- Copy the result or download it as .xml or .json.
What it offers
- Two-way conversion in separate editable panels
- Documented mapping for attributes, text, repeated and nested elements
- Strict XML and JSON parsing with line and column errors
- DOCTYPE, entity and DTD declarations rejected for safety
- Correct XML escaping and validation of element names
- Unicode preserved; invalid XML characters reported
- Formatted output with indentation choice
- Copy, Download .xml, Download .json and sample data
Tips for best results
- Keep a copy of the original XML if comments or processing instructions matter.
- Wrap lists in a parent element so repeated items are easier to handle as arrays.
- Make sure JSON keys are valid XML names before converting to XML.
- Treat all converted values as text and convert types in your own code if needed.
- Validate the converted output in the system that will consume it.
Why people use it
Predictable
One consistent, documented mapping both ways.
Safe parsing
No DTDs or external entities are ever loaded.
Exact errors
Line and column for parsing problems.
Private
Conversion runs entirely in your browser.
Common questions
This runs entirely in your browser
No file or text you enter here is uploaded. Encoding and decoding happen on your device using native browser APIs — close the tab and nothing remains on a server.