XML ↔ JSON Converter - Structured data translator
Convert structured XML tags to JSON format or parse JSON to XML locally.
History
How it works
This tool converts structured data between XML and JSON locally in your browser. Attributes on XML nodes are converted to `@attributes` objects in JSON, and sibling elements with the same tag name are grouped into arrays.
About this tool
XML and JSON are two ways to describe structured data. XML came first with a tag-based syntax similar to HTML and still powers SOAP APIs, RSS, SVG, Office documents, government exchange formats and industrial protocols. JSON is younger and more compact, used by modern APIs, config files and NoSQL databases. This tool converts in both directions directly in the browser: paste XML to get JSON, or JSON to get XML back. Attributes, text content, nested nodes and repetitions are handled, and you can choose whether attributes should be prefixed with @ or mapped to regular fields.
How to use it
- Paste the XML or JSON content into the text area.
- The tool detects the format automatically and shows the opposite one on the right.
- Tweak how attributes and text nodes are represented (@ prefix, "#text" key, etc.) if needed.
- Copy the result, or download it as .xml or .json for further use.
Examples
<person age="32">
<name>Anna</name>
<city>Oslo</city>
</person>{
"person": {
"@age": "32",
"name": "Anna",
"city": "Oslo"
}
}<list>
<item>a</item>
<item>b</item>
</list>{ "list": { "item": ["a", "b"] } }Common use cases
- Migrate legacy SOAP integrations to modern REST/JSON APIs.
- Convert government or EU XML exports to JSON for analysis.
- Debug RSS/Atom feeds in a more readable format.
- Convert SVG metadata to JSON for CMS ingestion.
- Generate fixtures for unit tests in whichever format is easier.
Frequently asked questions
- Why does the JSON have "@" in front of some keys?
- The convention separates XML attributes from elements. Without it, <person age="32"><age>old</age></person> would collide. You can turn the prefix off in settings if you don’t need to reverse the conversion.
- Is the conversion lossy?
- Slightly. XML has order, namespaces, comments and "mixed content" that JSON does not map cleanly. Simple data structures survive both directions, complex document-style XML should be reviewed manually.
- Are XML namespaces preserved?
- Yes. xmlns attributes are preserved as regular attributes (@xmlns or @xmlns:pfx). Converting back to XML restores the prefixes.
- Can the tool validate XML against an XSD?
- No. It only checks well-formedness. For XSD validation use a desktop tool (XMLSpy, Oxygen) or a library like libxml2, Saxon or Xerces.
Technical background
XML is a W3C standard from 1998, derived from SGML, with strict syntax: one root, properly nested tags, mandatory closing and encoding declaration. Attributes are strings, elements may contain text, other elements or both ("mixed content"). Namespaces (xmlns) resolve conflicts when two schemas use the same tag name. JSON is defined in RFC 8259 with only six types: object, array, string, number, boolean, null. Standard XML→JSON conventions (BadgerFish, JsonML, Parker) differ in how attributes and repetitions are mapped. This tool uses a simple variant: attributes become "@name", text content becomes "#text", multiple elements with the same name become an array. For the reverse, those conventions are used to reconstruct a valid XML structure. For fully accurate conversion of document-style XML (HL7, XBRL, Office) use domain-specific libraries that understand the semantics.