XML to JSON
This XML to JSON converter turns XML into a JSON object instantly. Tag attributes are kept as @_-prefixed fields by default, text alongside attributes uses a #text key, and attributes can be ignored if you prefer. XML is validated before parsing with errors located by line and column, and everything runs locally.
How to use it
- 1
Paste your XML
Paste XML text with or without an <?xml?> declaration; repeated tags, attributes and self-closing tags are all supported.
- 2
Choose whether to keep attributes
Attributes are kept as @_-prefixed fields by default; tick "Ignore XML attributes" to reconvert without them.
- 3
Copy the JSON
Choose the indentation and copy the standard JSON, or click ⇄ to send the result to the JSON to XML tool.
- 4
Reuse the output
Feed the JSON into a tool on this site or into your application code.
Key features
Attributes fully preserved
<a id="7"> becomes {"a":{"@_id":"7"}}, keeping attribute information, which can be turned off when not needed.
Repeated tags become arrays
A tag appearing more than once is merged into an array while a single occurrence stays an object, matching intuitive structure.
Strict validation first
Tag closure and other syntax are validated before conversion; <a> mismatched with </b> reports the line and column.
Entities decoded
Entity references such as &, <, > and " are restored to their original characters.
Works with SOAP and SVG
Suitable for well-formed XML including SOAP messages and SVG documents.
Local and private
Parsing happens in your browser and the data is not uploaded.
Common errors & troubleshooting
- ! Tags must be closed correctly; the line and column in an error point to the first mismatched closing tag.
- ! When an element has both attributes and text content, the text goes under a #text key, for example {"a":{"@_id":"7","#text":"hi"}}.
- ! A self-closing tag <x/> and an empty tag <x></x> both yield an empty string — XML cannot express null.
- ! HTML is not strict XML, so tidy it into XHTML style before converting.
Frequently asked questions
Where do XML tag attributes go?
By default they are kept as @_-prefixed keys (an id attribute becomes @_id) so they are distinguished from child elements. If you only care about content, tick "Ignore XML attributes" for a clean structure.
Why do some tags become arrays and others objects?
When a tag name appears twice or more under the same parent it is merged into an array; a single occurrence stays an object. This matches the convention of most XML data-binding tools.
Are SOAP, SVG and HTML supported?
It works for well-formed XML, including SOAP messages and SVG. HTML is not strict XML (it has many unclosed tags), so tidy it into XHTML style first.
Is my XML uploaded?
No. Parsing happens locally in your browser.
Related tools
JSON to XML
Convert JSON to well-formed XML with an XML declaration and indentation. The root element and array item tag names are configurable, and arrays become repeated same-name elements. Runs locally.
JSON Formatter
Format, beautify and validate JSON in your browser. Errors point to the exact line and column, and you can indent with 2 spaces, 4 spaces or a tab.
JSON to CSV
Convert an array of objects into CSV you can open in Excel or WPS. Columns are the union of all keys, nested objects flatten to dot-separated names, and comma, semicolon, pipe or tab delimiters are supported.
CSV to JSON
Convert CSV exported from Excel or WPS into an array of objects. The first row becomes the field names, numbers, booleans and null are inferred, and the delimiter is auto-detected. Runs locally.