ToolsMaxxing

JSON and XML converter

Convert JSON to XML and XML to JSON, keeping attributes if you want them.

Your files stay on your device

How it works

  1. 1Choose JSON to XML or XML to JSON.
  2. 2Paste your text, or choose Try an example.
  3. 3Set the root element name and whether attributes are used.
  4. 4Copy or download the result.

What the options do

Root element
XML needs exactly one root. When your JSON has several top-level keys, they are wrapped in this element.
Keys starting with @_ are attributes
In JSON a key such as "@_id" becomes the attribute id="..." on its element, and the reverse when reading XML.
Detect numbers and booleans
When reading XML, 42 and true become typed values instead of strings.

Privacy

Everything runs in your browser. What you paste is never sent to a server.

Questions people ask

How are repeated XML elements converted?

Several elements with the same name become a JSON array. A single one stays a plain value, so the shape can change depending on the data. Plan for that if you read the JSON in code.

Where do XML attributes go in JSON?

They become keys that start with @_ next to the child content. Text next to attributes is stored under #text.

Why does my JSON conversion add a root element?

XML documents must have one root. If your JSON is an array or has more than one top-level key, it is wrapped in the root name you choose, which defaults to root.

Does it keep comments and processing instructions?

No. Comments, CDATA wrappers and the XML declaration are not carried into JSON. The text inside CDATA is kept.

Does it validate against a schema?

No. It checks that the XML is well formed, meaning tags are balanced and attributes quoted, but it does not check an XSD or DTD.

Related tools