Free XML to JSON Converter
Convert XML documents into clean JSON in one click. Attributes, repeated elements (as arrays), text content, and CDATA are all mapped sensibly — perfect for dragging legacy XML APIs into modern JSON workflows.
JSON output
How to Use the XML to JSON
- Paste your XML document into the input box.
- Choose how attributes should appear (@attr or _attributes).
- Click Convert to JSON — the JSON appears instantly.
- Copy or download the result.
Features
Conversion uses the browser’s native DOMParser, so entity decoding and well-formedness checking are rock solid. Attributes map to @-prefixed keys (or a grouped _attributes object), repeated sibling elements automatically become arrays, mixed text lands in #text keys, and CDATA content is preserved as text. Malformed XML is rejected with the parser’s message.
Benefits & Use Cases
Developers modernize SOAP and RSS integrations by converting responses to JSON for JavaScript processing; data engineers bridge XML exports into JSON pipelines; anyone comparing API formats converts samples in seconds. Local conversion keeps payload contents private.
Tips
If an element sometimes appears once and sometimes multiple times, expect an object versus array inconsistency — normalize in code with a helper like [].concat(x || []). For huge documents, convert in chunks to keep the browser responsive.
Frequently Asked Questions
How are XML attributes represented in JSON?
By default as @-prefixed keys alongside the element’s children (e.g. {"@id": "1", "title": "x"}). You can switch to a grouped _attributes object if you prefer attributes separated from child elements.
What happens to repeated elements?
Repeated siblings with the same tag name become JSON arrays automatically —
How is text content handled?
An element with only text becomes a plain string value. Elements mixing text with child elements put the text in a #text key so nothing is lost.
Are comments and processing instructions kept?
Comments are dropped (JSON has no comment equivalent in data); processing instructions outside the document element are skipped. CDATA sections are preserved as their text content.
Is my XML uploaded anywhere?
No. Parsing and conversion run entirely in your browser — your data never leaves your device.
Related Tools
XML Formatter
Format and beautify XML instantly with NToolHub’s free formatter. Validates well-formedness, clean indentation — 100% private.
Open tool →XML Validator
Validate XML well-formedness instantly with NToolHub’s free validator. Clear verdicts, parser error details — 100% private.
Open tool →JSON to CSV
Convert JSON arrays to CSV spreadsheets with NToolHub’s free tool. Proper quoting, custom delimiters — opens in Excel, 100% private.
Open tool →YAML to JSON
Convert YAML to JSON instantly with NToolHub’s free tool. Handles mappings, sequences, nested structures — private in-browser.
Open tool →JSON Formatter
Format and beautify JSON instantly with NToolHub’s free formatter. Syntax validation, error location, stats — private in-browser tool.
Open tool →