XML to JSON

Convert XML to JSON as you type. Attributes, repeated elements and text are all kept, and any error shows its line and column.

Your files stay on your device. Nothing is uploaded.

XML to JSON

Converts as you type · files up to 20 MB

Step 1: Paste or open your XML

Step 2: Options

JSON layout
XML attributes

An attribute such as id="7" becomes "@id": "7". Text next to attributes goes in "#text".

Step 3: Copy or download

How to convert XML to JSON

  1. Paste or open your XML

    Paste XML into the first box, or click Open a file. The conversion runs as you type.

  2. Choose the options

    Choose the JSON layout, from 2 spaces to one line, and whether to keep XML attributes.

  3. Copy or download

    Click Copy JSON, or Download .json for a file.

About this tool

How XML maps to JSON

XMLJSON
<city>Lahore</city>"city": "Lahore"
<item id="7">Tea</item>"item": {"@id": "7", "#text": "Tea"}
Two or more <item> elements"item": [ ... ] (a list)

Values stay exactly as written

XML has no number or true/false types, so every value stays text: "007" stays "007" and "1.50" stays "1.50". The XML declaration and processing instructions are left out, as JSON has no place for them.

Errors you can fix

If the XML is not well formed, such as a tag that is never closed, the message gives the line and column, for example "Line 3, column 5: Expected closing tag".

Privacy

This tool runs in your browser, on your own device. Your files and text are not uploaded to our server and we cannot see them. When you close or reload this tab, they are cleared, along with the results.

Frequently asked questions

Can I convert JSON back to XML?

Yes, with JSON to XML, which turns @keys back into attributes.

Does it handle namespaces?

Yes. Prefixed names such as soap:Body are kept as they are in the keys.

Is my data sent anywhere?

No. The conversion runs in your browser.

Is there a size limit?

Files up to 20 MB. Very large text may take a moment to convert.