Skip to content
JustTools

XML to JSON Converter

Turn XML into clean JSON — or JSON back into XML — as you type. Attributes, repeated elements and IDs with leading zeros are handled correctly, and errors point to the exact line.

Runs in your browser Free · no sign-up

At a glance

  • Converts XML to JSON and JSON to XML, instantly as you type.
  • Attributes become keys with a prefix (@ by default), text beside attributes goes into #text, and repeated elements become arrays — all configurable.
  • Numbers and booleans are converted safely: values with leading zeros (007) or more than 15 significant digits stay as text, so IDs and codes are never changed.
  • Always use arrays keeps the JSON shape the same whether an element appears once or many times.
  • Invalid XML or JSON is reported with the exact line and column. CDATA, entities and namespaces are supported.
  • Copy the result or download it as a .json or .xml file.
  • Runs in your browser: the data you paste or open is never uploaded.

Step by step

How to convert XML to JSON

  1. 1

    Add your XML

    Paste XML into the input, or click Open file to load an .xml, RSS or other XML file.

  2. 2

    Adjust the options

    Open Options to change the attribute prefix, keep every element as an array, or turn off number conversion.

  3. 3

    Check the result

    The JSON appears as you type. If the XML has an error, its line and column are shown.

  4. 4

    Copy or download

    Copy the JSON or download it as a file. Choose JSON → XML to convert in the other direction.

Features

Everything you need, nothing you don’t

Both directions

XML → JSON and JSON → XML in one tool. Switching direction carries the result across, so you can convert back and forth.

Safe numbers

Unlike many converters, it never turns “00482” into 482 or rounds a 20-digit ID. Only values that convert exactly become numbers.

Predictable arrays

Turn on Always use arrays so code that reads the JSON works the same for one item or a hundred.

Exact error locations

An unclosed tag or a missing comma is reported with its line and column, and one click jumps to it in the input.

Your naming

Choose the attribute prefix (@, _, -, $), rename the text key, drop namespace prefixes or ignore attributes entirely.

Private

Configs, API responses and feeds are converted on your device. Nothing is sent to a server.

How XML maps to JSON

XMLJSON
<name>Asha</name>"name": "Asha"
<user id="7"/>"user": { "@id": 7 }
<price currency="INR">799</price>"price": { "@currency": "INR", "#text": 799 }
<tag>a</tag><tag>b</tag>"tag": ["a", "b"]
<sku>00482</sku>"sku": "00482" (leading zero kept)
<empty/>"empty": ""
<![CDATA[<b>bold</b>]]>"<b>bold</b>"

How JSON becomes XML

  • Keys that start with the attribute prefix (@id) become attributes; the #text key becomes the element’s text.
  • Arrays repeat the element: "item": [1, 2] becomes <item>1</item><item>2</item>.
  • null and empty strings become empty elements like <notes/>.
  • XML needs one root element, so data with several top-level keys, or a top-level array, is wrapped in <root>.
  • Keys that aren’t valid XML names are made valid: "first name" becomes <first_name>, "2nd" becomes <_2nd>.
  • Numbers are written exactly as they appear in the JSON, and &, < and > are escaped.

FAQ

Frequently asked questions

Is it safe to convert confidential XML here?

Yes. Conversion happens in your browser, so API responses, configs and feeds are never uploaded or stored.

Why are some numbers kept in quotes?

Values like 00482 or 20-digit IDs would change if turned into JSON numbers, so they stay as text. Turn off Convert numbers & booleans to keep every value as text.

Why is a single element not an array?

By default an element becomes an array only when it repeats. Turn on Always use arrays to make every element an array, so the structure never changes with the data.

What happens to attributes?

They become keys with a prefix — @id by default — placed before the element’s children. You can choose _, - or $ instead, or ignore attributes.

Are XML comments kept?

No. JSON has no comments, so XML comments and the <?xml ?> declaration are dropped. CDATA content is kept as text.

Can I convert JSON to XML?

Yes. Choose JSON → XML. Keys starting with @ become attributes and arrays become repeated elements, so XML converted to JSON here converts back to the same XML.

Does it work with RSS, SOAP and sitemap files?

Yes — any well-formed XML. Use Remove namespace prefixes for cleaner keys from SOAP and RSS media tags.

Keep going

Browse every tool

Last updated Report a problem or suggest a feature