XML to JSON conversion

Convert XML to JSON for APIs and configs

APIs and configuration systems increasingly expect JSON, but legacy services still return XML. The XML formatter now converts XML to a JSON structure locally, mapping elements, attributes, and text in a predictable way.

01

Convert in four steps

The same tool formats XML or converts it to JSON.

2

Paste the XML

Paste the XML document or open a local file.

3

Choose Convert to JSON

Switch the conversion option from Format to JSON.

4

Copy the result

Copy the JSON into your code or configuration.

02

How the structure is mapped

Each element becomes an object. Attributes are prefixed with @, child elements become properties, repeated children become arrays, and text content is kept under #text when mixed with children.

This mapping is deterministic, so the same XML always produces the same JSON, which makes it safe to script.

03

Where XML to JSON gets tricky

  • Repeated elements that need to become arrays
  • Attributes mixed with child elements
  • Mixed text and element content
04

Best practices

  • Validate the XML before converting
  • Check repeated elements become arrays
  • Validate the JSON with the JSON formatter after conversion
05

Frequently asked questions

How are repeated elements handled?

Repeated child elements become arrays, so a list of items stays a list in JSON.

What happens to attributes?

Attributes are kept and prefixed with @, for example @id, so they do not collide with child element names.

Can I convert back to XML?

This tool converts XML to JSON. The JSON formatter handles JSON formatting and validation.

Is my XML uploaded?

No. Everything runs locally in your browser.

06

Your data stays local

Conversion runs in your browser. The XML and the JSON never leave your device.

Open XML Formatter