JSON to XML

Convert JSON to XML online for free. Paste JSON and get well-formed XML instantly, in your browser.

Suggested tools

XML to JSON

Convert XML into clean JSON.

XMLJSON
Open Tool

XML Formatter

Beautify, minify and validate XML instantly in your browser.

XML
Open Tool

XML to CSV

Turn list-style XML into a CSV table, one row per record.

XMLCSV
Open Tool

CSV to XML

Convert CSV rows into well-formed XML elements.

CSVXML
Open Tool

XML to YAML

Convert XML into YAML.

XMLYAML
Open Tool

YAML to XML

Convert YAML into XML.

YAMLXML
Open Tool

About JSON to XML

JSON to XML converts JSON into well-formed, indented XML for APIs, legacy systems and configuration files. Objects become elements, arrays become repeated elements, and special characters are escaped correctly.

XML needs exactly one root element: if your JSON has a single top-level key it becomes the root; otherwise the data is wrapped in <root> (and array items in <item>). Keys that are not valid XML names are made safe automatically. It runs entirely in your browser, so nothing you paste is uploaded.

How to use JSON to XML

  1. Paste JSON, upload a .json file or click Sample.
  2. Press Convert.
  3. Copy or download the XML.

Key features

  • Well-formed, indented XML output
  • Arrays become repeated elements
  • Automatic root element when needed
  • Invalid tag names made safe

Example

Arrays become repeated elements; the single top-level key becomes the root element.

Input
{"order":{"id":5001,"customer":"Ravi Shah","items":[{"sku":"PEN-01","qty":2},{"sku":"NB-07","qty":1}]}}
Output
<order>
  <id>5001</id>
  <customer>Ravi Shah</customer>
  <items>
    <sku>PEN-01</sku>
    <qty>2</qty>
  </items>
  <items>
    <sku>NB-07</sku>
    <qty>1</qty>
  </items>
</order>

When to use JSON to XML

  • Sending JSON data to an older API or system that only accepts XML.
  • Generating XML test data from JSON fixtures.
  • Converting configuration between formats.

Tips and common problems

  • Use keys that are valid XML names (letters first, no spaces) to avoid automatic renaming.
  • Prefix keys with @_ to create attributes.
  • Wrap your data in one top-level key to control the root element name.

Frequently asked questions

Prefix a key with @_ — for example {"book": {"@_id": "7", "title": "X"}} gives <book id="7"><title>X</title></book>.

Guides

  • How to Convert JSON to CSV — How to convert JSON to CSV: how arrays of objects map to rows and columns, how nested objects are flattened, and how to avoid losing data.
  • JSON vs XML vs YAML — JSON vs XML vs YAML compared: strengths, weaknesses and best uses, to help you choose the right data format for APIs, config files and documents.