Developer tool / 01

XML to JSON Converter

Turn an XML document into readable JSON, with attributes and repeated elements handled sensibly.

XML to JSON Converter: TOEA reads the document's elements, attributes, text, and CDATA, then folds them into JSON: attributes are prefixed with @, loose text becomes #text, and repeated sibling names become an array. Runs 100% locally in your browser with zero server file uploads.

Runs
In your browser
Cost
Free · no sign-up
Availability
Ready to use
XML → JSON deskLocal processing

Runs entirely in your browser

↥
Paste XML below, or choose a file

Up to 5 MB · nothing is uploaded

Everything arrives as text

XML has no data types, so <count>42</count> becomes "42" and <active>true</active> becomes "true". Convert numbers and booleans in the code that reads the JSON, where you know which fields they are. The same applies to attributes: @id holds a string even when it looks numeric.

Code reading the result also has to cope with elements that repeat only sometimes. An <item> that appears once is an object, two are an array, so normalise with Array.isArray(x) ? x : [x] before looping.

Documents that do not convert well

The conversion suits data: configuration, API responses, feeds, and exports. It suits prose poorly. In <p>Read <b>this</b> first</p> the loose text is joined into one #text value and the bold word becomes a separate key, so the reading order is lost. XHTML, DocBook, and similar document formats are better processed with an XML library. To inspect a document's structure before converting, indent it with the XML formatter.

How to use it

  1. Paste XML or choose a file.
  2. Pick an indent width.
  3. Copy or download the JSON.

Privacy & limitations

The text is converted in your browser and never uploaded, which matters when the file is a config or an export you would rather not hand to a stranger. Namespaces are kept verbatim in element names rather than resolved.

Related tools

Frequently asked questions

Why do attributes start with @?

XML separates attributes from child elements; JSON has no such distinction. The @ prefix keeps them apart so the conversion can be reversed without guessing.

Why did one element become an array?

Repeated sibling names always become an array, because that is what the structure means. A name that appears once stays a plain value.

What is #text for?

An element holding both text and child elements needs somewhere for that loose text to live, and #text is that slot.

What is not supported?

DTD entity definitions, namespace resolution, and processing instructions beyond the declaration. Configuration files and API payloads do not use them.

Free tool · runs in your browser · no account required