AZ Tools

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.

Output
<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

  1. Pick the direction (JSON → XML or XML → JSON).
  2. Paste your data into the input box; the output updates live.
  3. Set the root element name when going JSON → XML if your input doesn't have a single top-level key.
  4. 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