XML to JSON Converter

Paste XML and get clean, formatted JSON instantly — parsed with a real XML parser, not regex.

JSON output

🔒 Your data never leaves your browser — all conversion happens locally.

How to use the xml to json converter

  1. Paste your XML into the left panel — a working example is preloaded.
  2. Toggle whether to ignore attributes, parse numbers/booleans, and pretty-print.
  3. Read the converted JSON on the right, updated live as you type.
  4. Click "Copy output" to grab the result.

How it works

This converter uses a real XML parser (fast-xml-parser), not string manipulation, so nested elements, attributes, and repeated tags all convert correctly. The conversion follows one clear, documented convention: attributes become object keys prefixed with @_ (e.g. importance="high" becomes "@_importance": "high"), text content alongside child elements is stored under a #text key, and any element repeated under the same parent becomes a JSON array. Whitespace-only text is trimmed. You can toggle off attribute parsing or numeric/boolean coercion if you want plain strings instead.

Examples

InputResult
<to>Tove</to><from>Jani</from>{"to":"Tove","from":"Jani"}
<tag>a</tag><tag>b</tag> (repeated element){"tag":["a","b"]}

Frequently asked questions

Is my XML uploaded anywhere?

No. Parsing happens entirely in your browser using JavaScript — your XML never leaves your device.

How are XML attributes represented in the JSON?

Each attribute becomes a key prefixed with @_ on the parent object, e.g. <note importance="high"> becomes {"note": {"@_importance": "high", ...}}. You can turn this off with the "Ignore attributes" option.

Why do some elements become arrays and others don't?

If an element tag appears more than once under the same parent, the parser groups them into a JSON array so no data is lost. A single occurrence stays a plain object or value.

What happens to text mixed with child elements?

Mixed text content is stored under a #text key alongside the parsed child elements, so nothing is discarded.

What if my XML is invalid?

The tool validates your XML first and shows a clear parser error with the line number, instead of guessing or crashing.