Convert XML to JSON
Turn XML into JSON with attributes, CDATA and namespaces handled the way you choose, and syntax errors that name the exact line.
Drop your files here
.xml, .rss, .svg, .xhtml, .txt · up to 300 MB
More settingsFewer settings
How to Convert to JSON
- 1
Drop an XML file
Add one file or up to twenty. RSS feeds, SVG drawings and XHTML pages are all XML and are read the same way.
- 2
Choose how attributes and repeats map
Attributes can be prefixed, grouped under one key or skipped, and repeated tags can always become arrays or only when they actually repeat.
- 3
Convert and download the JSON
Press the button and save the indented result. A batch of files comes back as one ZIP archive.
One element or a list of one
The awkward part of any XML-to-JSON mapping is a list with a single member: <order> with three <item> children obviously becomes an array, but the same document with one item looks like a plain object, and code that loops over it breaks on the very first real customer. That is why the array rule is an explicit setting rather than a hidden heuristic, and why you can force every child into an array.
Numbers that are not numbers
Smart typing converts 42 into a number and true into a boolean, which is usually what you want and occasionally a disaster. A part code of 00123 must not become 123, and a twenty-digit tax identifier must not be rounded into scientific notation. Values with leading zeros and digit strings longer than fifteen characters therefore stay strings, and turning typing off keeps every value exactly as written.
Entity declarations are refused
A DOCTYPE containing an <!ENTITY> declaration is rejected before parsing starts. Ten nested entities, each referring to the previous one ten times, expand into gigabytes of text and freeze the tab, the classic billion laughs. Nothing is expanded here beyond the five predefined entities and numeric character references, so the attack has nothing to unfold into.
Parsed here, not somewhere else
The parser runs in your browser, in a worker thread, on code that came with the page. Your XML is never uploaded, so there is no server copy to delete, no queue to wait in and no log to worry about. When the tab closes, the document and the JSON built from it are gone.
Frequently asked questions
Where do XML attributes end up in the JSON?
By default each attribute becomes a key on the same object as the element's children, prefixed with @_ so it cannot collide with a child tag of the same name. You can instead collect all attributes into one @attributes sub-object, which keeps element content clean, or drop attributes altogether.
Why is a single repeated element not an array?
Because nothing in the document says it is a list. With the default rule, a tag becomes an array only when it actually appears more than once under the same parent, which mirrors the file exactly. If your consumer needs a fixed shape, switch the array setting to always so that even a lone child arrives as an array of one.
What happens to CDATA sections?
By default CDATA content is merged into the element's text, since CDATA is only a quoting style and not a separate kind of data. If you need to know which part of a value was quoted that way, when re-emitting XML later for instance, switch to separate and it lands in its own #cdata key.
Can I remove namespace prefixes?
Yes. Stripping namespaces turns dc:title into title, which makes feed and document formats far easier to address in code. Leave it off if two different namespaces use the same local name in the same file, because then the prefix is the only thing keeping the keys apart.
Why do I get an error about custom entities?
Because a document declaring its own entities in the DOCTYPE is refused rather than expanded. That is the only reliable defence against entity expansion bombs, which can turn a few kilobytes into gigabytes of memory. Remove the DOCTYPE block and the rest of the document converts normally.
Do RSS feeds and SVG files work?
Yes, both are ordinary XML. An RSS feed converts into an object of channel metadata with an array of items, which is a convenient shape to work with. An SVG converts into its element tree with all presentation attributes intact, useful for inspecting or rewriting drawings programmatically.
What happens if the XML has a syntax error?
You get the line, the column and the tag involved, for example a closing tag expected at line 214, column 5, instead of a bare parse failure. In a file with tens of thousands of elements that difference is the whole point, since it tells you where to look.
Does my file get uploaded anywhere?
No. Decoding, validation and conversion all run locally in your browser tab. No server is involved at any stage, so there is no copy of your document anywhere once you close the page.