XML to JSON Converter
Converts an XML document to JSON, stating plainly which shape decisions it made and why they matter.
Loading the tool…
How to use this tool
- Paste the XML you want converted.
- Decide how attributes should appear, and whether repeated elements should always become arrays.
- Turn on type conversion only if you are sure no identifier in the document merely looks like a number.
- Select Convert to JSON, then check one record against the original before trusting the whole file.
What xml to json does
XML and JSON do not describe the same kind of thing, so every converter has to make choices no standard settles. XML distinguishes attributes from child elements and JSON has only keys, so attributes are given an "@" prefix here. XML lets an element hold both text and children, so that text becomes a "#text" key. And XML has no array: three <tag> siblings are just three elements.
That last one is the trap worth knowing about. Repeated siblings become a JSON array, but an element that happens to appear once becomes a single value rather than a one-item array — so two documents of the same type convert to two different shapes when one of them has a single item. Anything reading the result then has to handle both. Switch on "always use arrays" if the consumer is code rather than a person.