XML ↔ JSON

Convert XML to JSON and JSON to XML: attributes, text and repeated elements follow a clear convention and you can change the prefix, arrays and types. Everything in the browser.

Your data stays on your computer. Files are processed in your browser and are never uploaded.

Drop an .xml or .json file on this area (up to 5 MB), or

Convention

Attributes become keys with the chosen prefix (@id), the text of an element that also has attributes or children is in #text, children with the same name become an array and an empty element becomes null. The reverse direction uses the same rules.

What is lost

Comments and processing instructions do not make it to JSON. In mixed content (text between tags) the text is joined into #text and its position is not kept. Namespaces stay in the names (ns:tag) without being interpreted.

Where your data goes

The conversion runs in your browser: no data is sent to a server.

Keyboard shortcuts

In this tool

This tool has no keyboard actions.

Everywhere

Open this panel (outside text fields)
?
Closes panels and menus, never clears data
Esc
Search for a tool
/ or CtrlK

How to use it

  1. Choose the direction (XML → JSON or JSON → XML) and paste the text or drop a file.
  2. Set the attribute prefix, arrays and types (numbers and booleans); in JSON → XML choose the root name and whether to add the declaration.
  3. Copy or download the result; "Send to…" passes it to other tools, and "Swap" feeds the result back in to check the round trip.

Frequently asked questions

How are attributes and text translated?

An attribute id="1" becomes the key "@id": "1". If the element also has attributes or children its text is in "#text"; otherwise the value is the text itself.

Why is a single child not an array?

Because in XML an element repeated only once cannot be told apart from a unique one. With "Always arrays for children" every child becomes an array, useful when the data must always have the same shape.

Is my data sent to a server?

No: the conversion runs in your browser.

Privacy

The document stays in your browser: it is not sent to any server.

Tool chains

Link several tools into a path: after using a tool, “Send to…” offers the next step first. Saved chains keep only a name and the tools, never your data.

Saved chains

No saved chains.

New chain