Convert XML to JSON
Convert XML to JSON in your browser: load your XML, choose JSON as the target, and download the result. The converter reports exactly what it could not carry across, and nothing is uploaded to a server.
Convert XML to JSONRuns in your browser. Nothing uploaded.
When you need this
A legacy service replies in XML and your code would rather hold objects than walk a DOM. Converting once at the boundary is smaller and easier to test than teaching an entire codebase XPath, and it is the standard shape of an adapter around an old integration.
How to convert XML to JSON
- Load your XML
- Drag the .xml file in, or paste the document. A response captured from a SOAP or REST endpoint can go straight in as text. Nothing leaves your browser at this or any later step.
- Choose the target format
- Press Ctrl+Shift+K (Cmd+Shift+K on a Mac) to open the conversion panel, then pick JSON as the target. The source and the result sit side by side.
- Read the loss report
- The panel shows whether the conversion is lossless for your particular data, and lists every value it had to transform. Adjust indentation, key sorting and null handling if you need to.
- Take the JSON
- Download the .json file, copy it, or open it as a new tab to keep working on it in the JSON views.
What survives the conversion
XML to JSON cannot be lossless, because the two formats express different things. Attributes and child elements collapse into one namespace (prefixed "@_"), and element order is not preserved.
- Attributes and child elements share one namespace in JSON. Attributes are prefixed
@_so<a id="1"><id>2</id></a>does not collapse two different things into one key. - Element order is not preserved. JSON object keys are unordered by specification, so a document whose meaning depends on sequence needs an array, which means the source XML was already relying on something JSON cannot express.
- Mixed content — text and elements interleaved inside one element — has no clean JSON equivalent, and is the case most likely to lose something. It is reported rather than quietly flattened.
- Numeric-looking text becomes a number. XML has no types of its own, so
<id>2</id>andid="1"both arrive as JSON numbers — usually what you want, and wrong for an identifier like007. Turn type inference off when a field is a reference rather than a quantity.
A worked example
An attribute and a child element of the same name, kept apart:
<item id="1"><id>2</id></item>{
"item": {
"id": 2,
"@_id": 1
}
}Privacy
The conversion runs in your browser — in a Web Worker for anything above a quarter of a megabyte, so the page stays responsive. Your data is not uploaded, not logged and not stored. There is no account, and the whole thing works offline.
Questions
Why are attributes prefixed with @_?
To keep them distinguishable from child elements. XML allows an attribute and an element to share a name — the example above has both an id attribute and an id element — and without a prefix one would silently overwrite the other. The prefix is a widely used convention, and it makes the mapping reversible.
Is converting XML to JSON lossless?
No, and no tool can make it so. Attributes and child elements collapse into one namespace (prefixed "@_"), and element order is not preserved. The converter lists every affected value rather than silently dropping it.
Is my XML uploaded to a server?
No. The file is read and converted by your browser. Nothing about its contents is sent anywhere, which you can verify in your browser’s network panel or by using the tool with the network disconnected.