JSON ↔ XML Converter
Convert
Bidirectional JSON ↔ XML conversion via `fast-xml-parser`. JSON objects map to nested elements; arrays repeat the parent element. On the JSON side, attributes are represented with a leading `@_` (so `<book id="1">…</book>` becomes `{ "book": { "@_id": 1, … } }`). Output runs entirely in your browser — your data never leaves the page.
<library>
<name>AZ Tools</name>
<books>
<title>Hello</title>
<year>2024</year>
</books>
<books>
<title>World</title>
<year>2025</year>
</books>
</library>How to use
- Pick the direction (JSON → XML or XML → JSON).
- Paste your data into the input box; the output updates live.
- Set the root element name when going JSON → XML if your input doesn't have a single top-level key.
- Hit ↔ to swap directions, feeding the current output back as input.
Frequently asked questions
- How are XML attributes represented in JSON?
- With a `@_` prefix on the property name — `<book id="1">` becomes `{ "@_id": 1 }`. The prefix marks attributes apart from child elements with the same name.
- What happens with repeated XML elements?
- Two or more siblings with the same tag name become a JSON array. A single occurrence stays a plain object — there's no way for the parser to know an element is "supposed to be" an array if only one shows up.
- Does the converter handle namespaces, CDATA, and comments?
- Namespaces pass through as-is in element/attribute names. CDATA contents are returned as plain string values. Comments and processing instructions are dropped from the output.
- Are numeric and boolean strings auto-typed?
- Yes. `<year>2024</year>` becomes `"year": 2024` and `<active>true</active>` becomes `"active": true`. Strings that happen to look like numbers may also be coerced — wrap them in extra quoting at the source if that matters.
Related tools
CSS Unit Converter
Convert between px, rem, em, pt, vw, vh, and % using your own base font size and viewport.
JSON ↔ YAML Converter
Convert JSON to YAML or YAML to JSON — pick the indent and copy the result.
Data Size Converter
Convert between bytes, KB, MB, GB, TB — in decimal (1000) or binary (1024).
Roman Numeral Converter
Convert between Arabic numbers and Roman numerals from 1 to 3999.
Number Base Converter
Convert numbers between binary, octal, decimal, and hexadecimal.
Unit Converter
Convert length, weight, temperature, area, volume, speed, and time.