JSON to XML Converter

Convert JSON to XML in your browser. The XML is always well-formed: keys and characters XML cannot hold are renamed or escaped, and listed. Copy or download it.

Loading tool…

How it works

Paste or open a file

Paste JSON, open a file up to 5 MB, or drop one on the box. It is read in this tab and never uploaded.

Pick the options

Name the root element, choose the indent, and decide whether @keys become attributes.

Copy or download

Check the list of changes, then copy or download the XML.

How are arrays converted?

Each item becomes an element named after the array's key: {"tag": ["a", "b"]} gives <tag>a</tag><tag>b</tag>. A top-level array, or a list inside a list, gets <item> elements. An empty array under a key has nothing to repeat, so it is left out and listed. null and {} become an empty element, <a/>.

Source: XML 1.0 §3.1 Start-tags, end-tags and empty-element tags

What happens to keys that are not XML names?

An XML name cannot be empty, start with a digit, - or ., or hold spaces and most symbols. Such keys are renamed: each character a name cannot hold becomes _, with _ added in front when needed, so "first name" becomes first_name and "1st" becomes _1st. A key like "a:b" keeps its colon only when its prefix is declared, for example with "@xmlns:a". Every rename is listed with its line.

Source: XML 1.0 names · Namespaces in XML 1.0

Which characters are escaped?

& and < always, and > too, so ]]> cannot appear in text. In attributes, quotes, tabs and line breaks are written as references, because a parser turns a raw tab or line break there into a space. Control characters such as U+0001 are not allowed in XML 1.0, even as references, so they become U+FFFD and are listed.

Source: XML 1.0 §2.4 Character data · §2.2 Characters · §3.3.3 Attribute-value normalization

How do attributes work?

With "@keys as attributes" on, "@id": "7" becomes id="7" and "#text" becomes the element's text: {"price": {"@currency": "EUR", "#text": "9.50"}} gives <price currency="EUR">9.50</price>. XML to JSON uses the same convention, so attributes and text convert back. Order is not always kept: text between child elements is written in one place, and elements with the same name are grouped.

Source: XML to JSON

Are big numbers kept?

Yes. Numbers are written as they appear in the JSON: 12345678901234567890 stays 12345678901234567890 and 1.10 stays 1.10. JavaScript's JSON.parse rounds integers past 2^53 - 1; this converter reads the JSON text itself. Key order is kept too.

Source: RFC 8259 §6 Numbers

Need data from a website, not a file?

Browser Use agents open pages in a real browser, including dynamic ones, and return structured data.