How to Convert XML to JSON
How do I convert XML to JSON?
Paste your XML into a converter, decide how attributes and repeated tags should behave, and run it. Attributes become keys prefixed with @, repeated elements become arrays, and the result is valid JSON you can format or validate next. The conversion runs entirely in your browser.
The three steps
Open the XML to JSON converter, paste your XML into the left editor, or drop a file, then choose the options that match how you want attributes and arrays represented. Press Convert and the JSON appears on the right, ready to copy or download.
How attributes are handled
XML attributes become keys prefixed with @ so they can never collide with element keys. With attributes on, <person id="1"> becomes "@id": "1". You can toggle attributes on or off to get the full picture or just the element structure.
Elements, text, and CDATA
An element's text content becomes the value for its key. CDATA is treated as ordinary text. Comments, processing instructions, and DOCTYPE declarations are skipped so the output stays clean.
Repeated tags and arrays
XML has no arrays, so repeated sibling tags are the only signal. With "Preserve arrays" on, every repeated tag becomes an array even when it appears once. With it off, a single occurrence becomes a plain object or value, which keeps the JSON tidy but loses the array guarantee.
What to do with the result
The output is plain JSON, so it can be fed straight into a formatter or a validator. If the XML was large, the conversion runs in a background worker with a capped preview and a full download available.
FAQ
Why does my attribute have an @ in front of its key?
Attributes are prefixed with @ so they never collide with element keys. You can toggle attributes off to drop them from the output.
Can I convert XML to JSON without uploading?
Yes. The conversion runs entirely in your browser, in a background worker for large files. Nothing you paste or drop leaves your machine.
What happens to CDATA and comments?
CDATA becomes plain text. Comments, processing instructions, and DOCTYPE declarations are skipped.
Why did a single tag become an object instead of an array?
With "Preserve arrays" off, a tag that appears once becomes a single object or value. Turn it on to always emit an array for repeated tags.