JSON to XML Converter
Turn a JSON document into well-formed XML with control over the root element, attributes and formatting.
Processed locally in your browser/ Your data stays in your browser.
What is JSON to XML Converter?
Going from JSON to XML requires conventions too. Here object keys become elements, arrays become repeated elements with the same name, keys starting with a prefix (default @_) become attributes and a key such as #text holds the text of an element that also has attributes.
If your JSON has a single top-level key it becomes the root element; otherwise (arrays, scalars, several keys) the content is wrapped in the root name you choose. Text and attribute values are escaped, invalid XML characters are removed, and keys that are not legal XML names (spaces, leading digits) are renamed with underscores and reported, or rejected if you disable that fix. Big integers are written digit for digit.
How does it work?
- Paste your JSON.
- Set the root element name, attribute prefix and text node name if you need something other than the defaults.
- Choose the indentation, whether to add the XML declaration and whether empty elements should be self-closing.
- Copy or download the XML, or Swap to convert it back.
Common use cases
- Sending JSON data to a SOAP or legacy service that expects XML.
- Generating XML config fixtures from JSON test data.
- Producing RSS-like or sitemap-like XML from structured data.
- Round-tripping with XML to JSON to check a conversion.
Examples
Try this input in the tool above:
{"catalog":{"@_lang":"en","book":[{"@_id":"bk101","title":"XML Developer's Guide","price":{"@_currency":"USD","#text":44.95}},{"@_id":"bk102","title":"Midnight Rain","price":{"@_currency":"USD","#text":5.95}}]}}<?xml version="1.0" encoding="UTF-8"?>
<catalog lang="en">
<book id="bk101">
<title>XML Developer's Guide</title>
<price currency="USD">44.95</price>
</book>
<book id="bk102">
<title>Midnight Rain</title>
<price currency="USD">5.95</price>
</book>
</catalog>Privacy
JSON to XML Converter runs entirely in your browser. The text or files you provide are processed on your device and are not uploaded, logged or stored on our servers.
Limitations
JSON has no attributes, comments or namespaces, so those come only from your naming conventions. Arrays of arrays are wrapped in <item> elements because XML has no direct equivalent.
Frequently asked questions
How do I create attributes?
Prefix the key with @_ (or your chosen prefix): {"book":{"@_id":"1","title":"XML"}} becomes <book id="1"><title>XML</title></book>. Use #text for text next to attributes.
What happens when the JSON is an array?
XML needs a single root, so the array is wrapped: [1,2] becomes <root><item>1</item><item>2</item></root> with your root name.
What if a key is not a valid XML name?
By default it is renamed (first name becomes first_name) and listed in a warning. Disable the fix option if you prefer an error.
Related tools
XML to JSON Converter
Turn an XML document into JSON, keeping attributes, repeated elements and text content in a predictable structure.
JSON & Data
JSON Formatter & Beautifier
Turn a minified or messy JSON document into readable, consistently indented text, with a precise error message if the JSON is invalid.
JSON & Data
XML Formatter & Beautifier
Turn compressed or messy XML into a cleanly indented document that is easy to read and review.
JSON & Data
JSON to YAML Converter
Turn JSON into readable block-style YAML, with strings quoted only when necessary.
JSON & Data
JSON Validator
Check whether a piece of text is valid JSON and locate the exact character where it goes wrong.
JSON & Data
YAML to JSON Converter
Turn YAML into strict JSON, resolving anchors, aliases and merge keys along the way.
JSON & Data
JSON to CSV Converter
Paste a JSON array and get a CSV file ready for Excel or Google Sheets, with nested data flattened into columns.
JSON & Data