XML to JSON Converter
Paste an XML document and get a deterministic JSON representation, produced entirely in your browser.
JSON cannot represent every XML feature exactly. Unsupported structures are rejected or simplified according to the documented mapping.
How to use it
- Paste your XML document into the input area
- Choose an indentation option: 2 spaces, 4 spaces, or compact
- Select Convert to JSON
- Review the JSON output and use Copy to copy it
Element attributes are kept under an "@attributes" object, and every attribute and text value stays a string, so "true" or "00123" is never turned into a boolean or a number. Repeated sibling elements become a JSON array while a single element stays a direct value, and the original element order is preserved rather than sorted. Namespace prefixes and xmlns declarations are kept as written, CDATA sections become plain text, and comments, processing instructions and the XML declaration are dropped. For safety the converter refuses any DOCTYPE or ENTITY declaration before parsing, so external entity references and entity-expansion attacks cannot be processed, and it rejects mixed text-and-element content, multiple root elements and malformed markup instead of guessing a correction. Input is limited to about 2 MB, conversion runs only when you select Convert, and nothing you paste is uploaded, logged or stored. JSON cannot represent every XML feature exactly, so unsupported structures are rejected or simplified according to the documented mapping.
FAQ
Each element's attributes are collected into an "@attributes" object on that element, and every attribute value is kept as a string so numeric-looking or boolean-looking values are not changed.
When an element has two or more child elements sharing a name, those children are grouped into a JSON array; a name that appears only once stays a direct value, not a one-item array.
No. Comments, processing instructions and the XML declaration are ignored during conversion; only elements, attributes, text and CDATA content appear in the JSON output.
The converter refuses any DOCTYPE or ENTITY declaration before parsing. This stops external entity references and entity-expansion attacks from being processed at all, so such documents must be edited before conversion.
No. Conversion runs entirely in your browser when you select Convert, and the XML you paste and the JSON produced are never uploaded to a server, logged, or saved in browser storage.