XML to JSON
Convert XML documents
What is XML to JSON?
Convert an XML document to JSON, preserving attributes as "@name" keys when you want them. Two common use-cases: reading a legacy API that returns XML but you want to work in JSON, and exploring XML structure without squinting at tag pairs. The parser validates XML first, so you get a clear error if the source is malformed.
How do I use XML to JSON?
- Paste XML into the input panel.
- Toggle "Keep attributes" depending on whether you want them in the output.
- Copy or download the JSON.
When should I use XML to JSON?
XML to JSON keeps the tree structure. For flat tabular output (rows and columns), use XML to CSV. To convert in the other direction, JSON doesn't map cleanly to XML in general — use a dedicated tool for that round-trip.
How are attributes represented in the JSON?
With an "@" prefix by default — <a href="x">text</a> becomes {"a": {"@href": "x", "#text": "text"}}. Toggle "Merge attributes" for a flatter shape.
What if an element repeats?
Repeated siblings become an array automatically — the tool detects this by scanning the document. Single elements stay as objects.
Is the conversion lossless?
Close to, but not exactly. Mixed content (text interleaved with elements) is hard to round-trip cleanly. For complex XML, keep the original.
Is my file uploaded anywhere?
No. Everything runs in your browser. Your files never leave your device, and there is no server component for this tool.