Code Tools

JSON to XML

All tools

Wrap a JSON object in XML elements for systems that only accept XML payloads.

How it works

Four simple steps

1

Paste a JSON object

Start from an object; wrap top-level arrays in one first.

2

Keys become elements

Every key turns into a tag under a single <root> element.

3

Arrays repeat

List items become repeated elements named after the key.

4

Save data.xml

Copy the indented XML or download it as a file.

JSON to XML

About JSON to XML

A legacy SOAP service or an ERP import screen only accepts XML, but the data you have comes from a modern JSON API. Rather than typing tags by hand, paste the JSON and get an XML draft to adjust.

The converter wraps everything in a <root> element and adds an XML declaration. Each object key becomes an element with the same name, strings, numbers and booleans become text content (with &, < and > escaped), and null becomes an empty self-closing element. Arrays are written as repeated elements named after their key with a trailing s removed, so "tags": ["a", "b"] turns into two <tag> elements without a wrapper. The result is indented and can be downloaded as data.xml.

Two things need care. Keys are used as tag names unchanged, so keys with spaces, leading digits or symbols like @ produce invalid XML; rename them in the JSON first. And if the top-level value is an array, each item becomes its own <root> element, which leaves the document without a single root, so wrap the array in an object such as {"items": [...]}. Check the result by reading it back as JSON, tidy a hand-edited version in the XML Formatter, or produce a config-style file with JSON to YAML instead.

The mapping is done by a short recursive function in the page, without any conversion service involved.

Keyboard shortcut

Ctrl Enter - Run tool
FAQ

Frequently asked questions

See all FAQs

Answers for this tool. For site-wide help, open the FAQ hub.

Not in the tool. The root is always , but it appears only in the first and last tag of the output, so renaming it by hand is a two-word edit.

No. Every key becomes a child element. If the target system expects attributes, convert the relevant elements by hand after generating the draft.

The output passes through the site's indenter, which places element text on a separate line under its tag. Most XML parsers handle this, but systems that compare text exactly may need the whitespace trimmed.

View more FAQs

Related tools

View all

HTML Formatter

Beautify and indent HTML markup.

Open

CSS Formatter

Format and pretty-print CSS.

Open

JS Formatter

Beautify JavaScript code.

Open

JSON Formatter

Beautify and validate JSON.

Open

Explore 321 free tools

Everything you need as a developer, marketer or creator - in one beautiful place.

Browse all tools