XML to JSON Converter

Turn an XML file or pasted XML into JSON. Your data stays on your device.

  • Runs in your browser
  • No sign-up
  • No watermark

This converter reads XML with your browser's own parser and writes JSON. Attributes become keys that start with @. Text next to attributes or child elements is stored as #text. Elements that repeat, such as several <item> tags, become an array.

Nothing is uploaded. Comments and processing instructions are ignored, and surrounding whitespace in text is trimmed.

How to use XML to JSON

  1. Paste your XML, or choose or drop an .xml file.
  2. Pick the JSON layout.
  3. Tick the option to convert numbers and true/false if you want typed values.
  4. Copy the JSON or download it.

Frequently asked questions

Is my XML uploaded?

No. It is parsed in your browser and stays on your device.

How are attributes written?

As keys with an @ prefix, for example {"book": {"@id": "1", "title": "Dune"}}. Converting back with the JSON to XML tool turns them into attributes again.

When does an element become an array?

When a parent has two or more children with the same name. A single child stays a single value, so the shape of the JSON can differ between files with one item and files with many.

Are numbers converted?

Only if you tick the option. By default every value is text, which matches the XML exactly. With the option on, plain numbers and true or false become JSON numbers and booleans.

What if my XML is not well formed?

The tool reports the line and column of the problem, such as a tag that was not closed. Fix it and convert again.

What is not preserved?

Comments, processing instructions, the XML declaration and the order of mixed text and elements are not kept. Namespace prefixes stay as part of the names.