Convert JSON to XML

Need XML for a SOAP service, a feed or an older system that only reads XML? Paste JSON and get indented, well-formed XML, with special characters escaped and invalid names fixed.

  • Free
  • Runs in your browser
  • Well-formed output
  • No sign-up
How it works

How It Works

Convert JSON in three steps.

01

Paste JSON

An object or an array, from an API, a file or a database.

02

Name the elements

Set the root element, the name for array items and the attribute prefix.

03

Copy or download

Copy the XML or save it as converted.xml.

About

How JSON becomes XML

Each JSON key becomes an element and each value its content. An array becomes the same element repeated, so {"tag": ["a", "b"]} gives <tag>a</tag><tag>b</tag>. Keys starting with @ become attributes and a "#text" key becomes the element's text, which is the same convention our XML to JSON converter uses, so the two work as a pair. A JSON object with exactly one key uses that key as the root element; anything else is wrapped in the root element you choose.

XML has no types, so numbers and true/false become plain text. Whoever reads the XML decides how to interpret them.

Attributes from @ keys

{"@id": 7} becomes id="7" on the element. Clear the prefix to turn every key into an element.

Valid element names

XML names cannot start with a digit or contain spaces, so "1st item" becomes _1st_item.

Escaped content

&, <, >, quotes and apostrophes are escaped so the output always parses.

null as empty element

A null value becomes a self-closing element such as <middleName/>.

Features

Why Use This Converter

Clean XML from any JSON.

Pairs with XML to JSON

The same @ and #text convention in both directions.

Your element names

Choose the root and array item names to match a schema.

Readable or compact

Indent with 2 or 4 spaces, or put everything on one line.

Private

Converted in your browser.

✓ No Registration✓ Free✓ Browser-based✓ Text Stays Local
FAQ

Frequently Asked Questions

Questions people ask about the JSON to XML converter.

XML needs exactly one top-level element. When the JSON is not an object with a single key, everything is placed inside the root element. Change its name in Root element.