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.
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.
How to use it
- Choose the direction (XML → JSON or JSON → XML) and paste the text or drop a file.
- Set the attribute prefix, arrays and types (numbers and booleans); in JSON → XML choose the root name and whether to add the declaration.
- 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.