JSON to XML Converter

Paste JSON, pick a root element name, and get valid indented XML — attributes, text and escaping handled, with a copy button, all in your browser.

  • Free
  • No account
  • Runs in your browser
  • Nothing uploaded
JSON to XML ConverterNothing uploaded
130 characters

Paste JSON and convert it to XML — attributes stay under @_ keys and text under #text, the way the XML to JSON converter reads them back.

Runs entirely in your browser — your input is never uploaded, logged, or stored.Privacy policy

What is JSON to XML Converter?

JSON and XML are two of the most common text formats for structured data. JSON is compact and native to JavaScript; XML uses tags and attributes, and is the format of many older systems, SOAP APIs, configuration files, and data feeds like RSS and sitemaps. When an API or a config tool only accepts XML but you have the data as JSON, you need a conversion.

This tool turns JSON into XML. You paste valid JSON, choose the name of the root element, and it returns the same data as a cleanly indented XML document. A JSON object becomes a set of nested elements, each key becoming a child element; arrays become repeated elements; numbers, strings and booleans become element text. Nothing is uploaded — the conversion runs entirely in your browser.

Attributes work like they do in the reverse XML to JSON Converter. A JSON key starting with @_ is written as an XML attribute, and a key called #text becomes the element's text content. That keeps the two tools compatible, so data converted one way and back again keeps its shape.

The tool parses your input as JSON first, so malformed JSON fails with a clear message before any XML is produced. It then walks the parsed value and builds the XML document:

• The root element is the name you choose; the whole JSON value is placed inside it. • An object becomes child elements — each key is an element name, each value is that element's content. • A key starting with @_ is written as an attribute on its parent element (dropping the @_ prefix). • The key #text sets an element's text content, for round-tripping with the XML to JSON Converter. • An array repeats its tag once per item; a scalar (string, number, boolean) becomes element text. • Reserved XML characters are escaped automatically, so & becomes &amp;, < becomes &lt;, and so on.

The output is pretty-printed with your chosen indentation and is valid, single-root XML — the tool rejects inputs with no single root rather than emitting broken markup.

Worked examples

  • {"name":"Alice","age":30}, root "user", 2-space → <user>\n <name>Alice</name>\n <age>30</age>\n</user>
  • {"user":[{"name":"Alice"},{"name":"Bob"}]}, root "users", 2-space → <users>\n <user>\n <name>Alice</name>\n </user>\n <user>\n <name>Bob</name>\n </user>\n</users>
  • {"@_version":"1","log":{"level":"info","file":"app.log"}}, root "config", 4-space → <config version="1">\n <log>\n <level>info</level>\n <file>app.log</file>\n </log>\n</config>
  • {"title":"a & b < c > d"}, root "note" → <note>\n <title>a &amp; b &lt; c &gt; d</title>\n</note> — one element contains text, so its content stays on one line and the special characters are escaped so the XML stays valid.
  • {"@_id":"1","#text":"Alice"}, root "user" → <user id="1">Alice</user> — @_ keys become attributes and #text becomes content, matching the reverse converter.

How to use JSON to XML Converter

  1. Paste valid JSON into the input box.
  2. Type the name you want for the root element (it defaults to root).
  3. Choose the indentation: 2 spaces or 4 spaces.
  4. Read the converted XML — or a clear message if the JSON is invalid or can't form a single root.
  5. Copy the output. Nothing is stored or uploaded; closing the tab is all the cleanup there is.

Common errors

  • The input is not valid JSON — the tool tells you rather than guessing. Check for trailing commas, missing quotes around keys, or a stray brace.
  • The top level is an array — [{"a":1},{"b":2}] has no single XML root, so the tool asks you to wrap it in an object (e.g. {"item":[...] }) or give your data a container.
  • A key isn't a legal XML element name — a key like "first name" or one starting with a digit can't become a tag. Rename it (or make it an @_ attribute) for valid XML.
  • The root name I chose isn't a valid XML name — XML element names can't start with a digit or a space. Pick a name like user or items.
  • An empty value came out as an empty element — empty strings, null, {} and [] all become a self-closing element like <key/> in XML, which can't tell them apart. That's a property of XML, not a conversion bug.

FAQ

Will converting JSON to XML lose any data?

For ordinary data — objects, arrays, strings, numbers, booleans — no, the structure carries over completely. Two limits are worth knowing. First, XML has no clean representation for an empty array, empty object, null, or empty string: they each become an empty element, and XML can't tell them apart. Second, JSON object keys become XML element or attribute names, so a key that isn't a legal XML name must be renamed or converted to an attribute first.

How do attributes work when converting to XML?

A JSON key that starts with @_ is written as an XML attribute on its parent element, with the @_ prefix dropped. For example {"@_id":"1","name":"Alice"} becomes <user id="1"><name>Alice</name></user>. This matches the XML to JSON Converter, which stores attributes under @_ keys — so the two tools round-trip cleanly.

Why do I have to choose a root element name?

Every XML document needs exactly one root element, but JSON has no built-in root — a JSON object just holds keys. So the tool asks you to name the root, then places the whole JSON value inside it. Typing a name is the only way to get valid, single-root XML.

What happens to special characters like & and < in my data?

They are escaped so the XML stays valid: & becomes &amp;, < becomes &lt;, > becomes &gt;, and quotes in attributes become &quot;. The escaping is done automatically, so a value like a < b & c survives intact even though the characters aren't allowed raw in XML.

Is my JSON uploaded anywhere?

No — the conversion happens entirely in your browser using a local JSON parser and XML builder. Nothing you paste is sent to a server.

How is this different from the XML to JSON Converter?

They are the reverse of each other. This tool turns JSON into XML; the XML to JSON Converter turns XML back into JSON. Using the same @_ attribute and #text conventions in both keeps them compatible, so data can move between the two formats and keep its shape.

G

Prefer AllUtil on Google

One click adds AllUtil to your Google preferences. You'll see our tools highlighted with a Preferred badge in Search and AI answers.

2× more likely to clickWorks in AI Overviews

Reviewed by unreviewed

Written by Hamza AK. We research, build and test every tool before it is published.

Editorial policy

Last updated

Rechecked against the sources on this date, not stamped.

Methodology

This tool parses the input as JSON (rejecting malformed JSON with a clear message), then builds a single-root XML document: the chosen root element wraps the value, object keys become child elements or @_ attributes, arrays become repeated elements, and scalars become escaped text. Inputs with no single root — such as a bare top-level array — are rejected rather than emitting invalid XML. Empty values (empty string, null, {}, []) each become an empty element and are indistinguishable in XML; keys that aren't legal XML names are reported. Conversion runs locally in the browser — nothing is uploaded.

JSON to XML Converter: Free, In-Browser — AllUtil