XML & JSON Converter
Map structured XML to a readable JSON object or build XML from a compatible object. Review the mapping rules before using the result as an interchange format.
Browser-based · No account required · Copy and export
XML ⇄ JSON Converter Workspace
Developer tools · EmeraldHow to use XML & JSON Converter
- Choose the conversion direction and paste data or load a local text file.
- Set indentation, whitespace handling and a fallback XML root. Enable mixed-content rejection if order loss would be unacceptable.
- Convert and inspect the result. Copy or save the output using the direction-appropriate extension.
When to use this tool
Move simple XML records into a JSON workflow or rebuild XML from the supported JSON representation. Attributes, repeated elements and mixed content need careful comparison after conversion.
XML and JSON have different data models
Attributes map to @name keys, text maps to #text when an object has other fields, and repeated sibling names become arrays. XML text stays text rather than guessing numbers or booleans. Mixed content can interleave words and elements; this object mapping groups values and cannot preserve that original order.
Worked example
<item id="7"><tag>a</tag><tag>b</tag></item>
becomes {"item":{"@id":"7","tag":["a","b"]}} Inspect attributes and repeated tags before using the mapping
Original XML practice input
<item sku="0012"><tag>draft</tag><tag>review</tag></item>
For this example, inspect the JSON for an item object, a text-valued @sku attribute and a tag array containing draft and review. Numeric-looking XML content is not automatically typed as a JSON number.
- Choose XML to JSON and paste the authored input. Keep strict mixed-content rejection enabled when preserving interleaved words and elements matters.
- Compare attribute names and repeated-element counts with the source. A single tag and repeated tags can produce different value shapes, so inspect more than one representative record.
- If returning to XML, check the chosen root and valid element/attribute names. Rebuilt markup need not reproduce source whitespace or presentation.
- Keep the original when mixed text, comments, namespace-sensitive processing or byte-for-byte fidelity matters. Disabling a rejection does not make the object mapping preserve mixed-content order.
Authored mapping exercise, not a supplied converted artifact. DOCTYPE input remains rejected. For expected JSON shape checks, use JSON Schema Validator; for text-level source review, use Text Diff.
Limits and output checks
This is a practical mapping, not lossless XML round-tripping. Comments, processing instructions, namespace semantics and mixed-content order are not retained. DOCTYPE input is rejected. Generated XML names use a restricted supported syntax; unsafe JSON integers are rejected.
Reference: XML document parsing.
Frequently asked questions
Are XML numbers converted to JSON numbers?
No. Element and attribute text remains strings.
What does mixed-content rejection do?
For XML input it rejects elements containing both child elements and meaningful text, avoiding silent acceptance of an order-losing mapping.
Will namespaces round-trip?
Not reliably through this simplified object mapping. Use a namespace-aware XML workflow when those semantics matter.
A practical object mapping, not XML preservation
Choose the conversion direction and inspect how attributes, repeated elements and text appear in the result. Use a representative element before converting a larger document.
Scope of this workflow
The simplified mapping does not preserve namespace semantics or mixed-content order. XML text stays strings rather than becoming inferred numbers.
JSON Schema Validator - Draft-07 Instance Checks · All developer tools · Privacy policy · Contact PixelOkay