Search tools

Find a tool by name or what it does.

JSON to XML Converter

Turn a JSON document into pretty-printed, well-formed XML, with control over the root element, array item names, and whether values become elements or attributes.

Converted live as you type. Nothing leaves your browser.

Scalar values

Indentation

XML declaration

How to convert JSON to XML online

  1. Paste your JSON

    Paste or type a JSON document into the input. The XML is generated live as you type, with parse errors shown inline.

  2. Name the elements

    Set the root element name and the element name used for array items so the output matches the schema you are targeting.

  3. Choose how values map

    Write string, number, and boolean values as nested elements, or fold them into attributes on their parent element.

  4. Copy the XML

    Copy the indented, well-formed XML or download it as an .xml file.

Why use this tool

Objects, arrays, and values

Objects become nested elements, arrays become repeated elements, and strings, numbers, and booleans become text nodes or attributes.

Valid names, escaped text

Property names that are not legal XML names are sanitized, and ampersands, angle brackets, and quotes in your data are escaped for you.

Elements or attributes

Choose whether scalar values are written as child elements or as attributes on their parent, and set the names used for the root and for array items.

Well-formed output, checked

The XML is pretty-printed with 2 or 4 space indentation, or minified, and checked so you can see it is well-formed before you copy it.

Handles the awkward cases

Empty objects and arrays, null values, and arrays mixing several types all convert to sensible XML instead of throwing errors.

Runs entirely in your browser

Everything happens on your device; nothing is uploaded.

About this tool

This tool converts a JSON document into XML entirely in your browser. It walks the JSON structure and maps it onto XML: objects turn into nested elements, arrays turn into repeated elements, and the primitive values inside become text nodes or attributes. The result is pretty-printed with your choice of indentation, so it is ready to read or paste straight into a file.

You control the shape of the output. Set the name of the root element that wraps the document, the element name used for each item in an array, whether scalar values are written as child elements or as attributes, and whether to include an XML declaration at the top. Property names that are not legal XML names, such as keys with spaces or a leading digit, are sanitized, and any ampersands, angle brackets, or quotes in your data are escaped so the result stays well-formed.

Reach for it whenever a system speaks XML but your data is JSON: SOAP endpoints, older enterprise APIs, RSS or sitemap fragments, and many configuration formats. Edge cases are handled rather than skipped, so empty objects and arrays become empty elements, null becomes an empty element or attribute, and arrays holding mixed types still convert cleanly. To go the other way, use the XML to JSON tool, tidy the input first with the JSON formatter, or indent existing markup with the XML formatter.

Frequently asked questions

How does it convert JSON to XML?
Objects become nested elements keyed by their property names, arrays become an element containing one child per entry, and strings, numbers, and booleans become text nodes or attributes. The result is pretty-printed with your chosen indentation.
Is my data uploaded anywhere?
No. Everything runs in your browser; nothing is sent to a server, stored, or logged. You can use it offline once the page has loaded.
What happens to keys that are not valid XML names?
They are sanitized. Characters that XML does not allow in element or attribute names are replaced with an underscore, and a name that starts with a digit or other non-letter gets an underscore prefix, so the output is always well-formed.
How are arrays and mixed types converted?
Each array becomes an element that holds one child per entry, named by the array item name (item by default). Nested arrays and arrays mixing strings, numbers, objects, and null all convert, with each entry rendered according to its own type.
Can scalar values become attributes instead of elements?
Yes. In attribute mode, string, number, boolean, and null properties are folded into attributes on their parent element, while objects and arrays stay as child elements. Element mode writes every value as its own nested element.
What if my JSON is invalid?
The tool shows an inline error with the parser message instead of crashing, and clears it the moment the input becomes valid JSON again. Empty input shows a neutral empty state.

Related tools