Developer

Encoders, converters & dev utilities

12 tools
Developer · Data-Format Converter (JSON ↔ CSV / YAML / XML)

JSON to XML Converter

Convert JSON into XML using a symmetric, documented mapping so the result round-trips back to the same JSON. Object keys become elements, arrays expand into a repeated element per item, and keys prefixed with @_ are written back out as attributes rather than child nodes — so {"a":{"@_x":"1"}} becomes <a x="1"></a> and {"r":{"item":["1","2"]}} becomes an <r> element with two <item> children. The output is pretty-printed with two-space indentation. JSON is parsed per RFC 8259 and the XML follows the W3C XML 1.0 conventions (attributes vs child elements, repeated tags for arrays). Runs 100% in your browser — your data never leaves the page. Free, no login.

Quick answer

Object keys → elements; array items → a repeated element each; @_-prefixed keys → attributes

  • Worked example — {"r":{"item":["1","2"]}} → <r><item>1</item><item>2</item></r>
  • Attributes: {"a":{"@_x":"1"}} → <a x="1"></a> (the @_ convention, reverse of XML→JSON)
  • Pretty-printed with two-space indentation; round-trips back to the original JSON
  • JSON parsed per RFC 8259, XML per W3C XML 1.0 — 100% client-side, nothing uploaded
Open the full Data-Format Converter (JSON ↔ CSV / YAML / XML)

Frequently asked questions

How do I convert JSON to XML?

Paste your JSON and it is serialized to XML. Object keys become element names, arrays become a repeated element per item, and keys written with an @_ prefix are emitted as attributes. So {"r":{"item":["1","2"]}} becomes <r><item>1</item><item>2</item></r>, and {"a":{"@_x":"1"}} becomes <a x="1"></a>. This mirrors the XML-to-JSON direction exactly, so a value converted one way and back is unchanged.

How do I make a JSON value become an XML attribute?

Prefix the key with @_. The builder treats @_-prefixed keys as attributes and every other key as a child element — the same convention used when parsing XML into JSON. So {"user":{"@_id":"1","name":"Ada"}} produces <user id="1"><name>Ada</name></user>. If you do not use the prefix, the value is written as a nested element instead of an attribute.

How are JSON arrays represented in XML?

XML has no array type, so an array is expanded into a repeated element — one element per array item, sharing the array's key as the tag name. {"list":{"item":["a","b","c"]}} becomes three <item> elements inside <list>. This is the standard XML idiom for a collection and is exactly what the XML-to-JSON direction collapses back into an array, so the round trip is faithful.

Related Data-Format Converter (JSON ↔ CSV / YAML / XML) pages