XML to JSON Converter
How to Use
Paste XML and the corresponding JSON appears immediately. Attributes are placed under `@attributes`, raw text under `#text`, and sibling elements with the same tag become arrays. Pick 2 or 4-space indent.
How the Conversion Works
XML and JSON are structurally different, so there's no clean 1:1 mapping. This tool uses a badgerfish-lite convention (`@attributes`, `#text`, arrays for repeated tags). It's good for inspecting SOAP responses, looking inside docx/xlsx, migrating XML configs, and similar tasks. For production-grade XML handling, use a dedicated library like fast-xml-parser or xml2js.
Use Cases
- Working with SOAP API responses as JSON
- Inspecting the inner XML of docx / xlsx files
- Migrating older XML configs to JSON
- Reviewing the structure of Atom / RSS feeds
- Converting XML to JSON to query with JSONPath
Privacy
Parsing and conversion happen entirely in the browser; the XML input never leaves your device. Internal config files or business data stay local.
FAQ
Where do attributes and text end up in the JSON?
An element's attributes are placed under an `@attributes` key, and the text the element directly contains goes under a `#text` key. This badgerfish-lite convention keeps XML attributes and body text distinguishable in JSON.
Is it safe to paste business XML?
Yes. Both parsing and conversion to JSON happen entirely in your browser, and the input is never sent to or stored on a server. You can safely try internal config files or confidential data.
What happens when there are multiple elements with the same name?
Sibling elements that share a tag are automatically converted into an array. For example, multiple <item> elements become an item array in JSON, preserving their order and count.
Can I use this tool for production conversion?
It's great for debugging, inspecting structure, and lightweight migrations, but XML and JSON are structurally different with no clean 1:1 mapping. For production-grade conversion, use a dedicated library like fast-xml-parser or xml2js.
Can I change the indentation?
Yes. You can choose 2-space or 4-space indentation for the output JSON, balancing readability and compactness to fit your needs.