glunty

JSON to XML Converter

Two-way JSON and XML conversion. Set the root element, get inline errors, copy the result. Local only.

Direction:

What this tool does

Converts structured data between JSON and XML in both directions. In JSON to XML mode it parses your JSON with the browser's built-in parser, then hand-writes an XML document: object keys become element names, arrays repeat their element name once per item, and primitive values become escaped text. Everything is wrapped in a single root element you can rename. In XML to JSON mode it parses the XML with the browser's DOMParser, checks that the document is well-formed, and walks the DOM into a plain object printed as pretty JSON. Invalid input never crashes the page: you get an inline error with the reason instead. Everything runs locally, so nothing you paste leaves your machine.

How to use it

Pick a direction. For JSON to XML, paste JSON in the input box, set the root element name if you want something other than root, and read the XML in the output box. For XML to JSON, paste XML and get JSON back. Conversion runs as you type and also on demand with the Convert button. Use Copy result to grab the output.

Example: paste {"note":{"to":"Tom","from":"Jane"}} in JSON to XML mode and you get:

<root>
  <note>
    <to>Tom</to>
    <from>Jane</from>
  </note>
</root>

A value that contains markup is escaped as it is written, so {"x":"a<b"} produces <x>a&lt;b</x> and stays well-formed. Switch to XML to JSON, paste XML back, and you get an equivalent object again.

Common use cases

  • Turning a JSON API response into an XML payload for a SOAP endpoint or legacy system.
  • Converting an XML config, RSS item, or SVG fragment into JSON a modern app can read.
  • Generating quick XML fixtures from a JSON sample for tests or mock services.
  • Reading a dense XML document as JSON because the nesting is easier to scan.
  • Checking that a hand-written XML snippet is well-formed before you ship it.

Common pitfalls

  • XML has one root only. Every XML document needs exactly one top-level element, so the tool always wraps your JSON in a single root element. When your JSON is an array at the top level, each item is wrapped in an item element so the result still parses.
  • XML has no types. Numbers, booleans, and null all become plain text on the way to XML, and every value comes back as a string on the way to JSON. A <count>2</count> becomes the string "2", not the number 2. Cast values yourself if you need real numbers.
  • Element names get sanitized. JSON keys can contain spaces and symbols that are illegal in an XML tag name. Those characters are replaced with underscores, and a key that starts with a digit is prefixed with one, so the output is always valid XML.
  • Attributes and comments do not survive to JSON. This converter maps elements and text only. XML attributes, comments, and processing instructions are not turned into JSON keys, so round-tripping a document that relies on them will lose them.

Frequently asked questions

How do I convert JSON to XML?
Paste your JSON into the input box with the direction set to JSON to XML. The tool parses the JSON, then walks the resulting value and emits an XML document. Object keys become element names, arrays repeat their element name once per item, and strings, numbers, and booleans become the text inside an element. The whole document is wrapped in a single root element, named root by default, so the output is always valid single-root XML.
How does the tool turn a JSON array into XML?
XML has no array type, so a JSON array is represented by repeating the same element name once for each item. For example the object {"tag": ["a", "b"]} becomes <tag>a</tag><tag>b</tag> inside the root element. When the top level of your JSON is itself an array, each item is wrapped in an item element so that the document still has exactly one root.
Can I change the name of the root element?
Yes. The root element field lets you set any name you like, and it defaults to root. XML requires exactly one top-level element, so the tool always wraps your data in this single root. Names are sanitized to a legal XML element name, so a space or other illegal character is replaced with an underscore and a leading digit is prefixed with one.
How are reserved characters like < and & escaped?
Text is XML-escaped before it is written, so an ampersand becomes &amp;, a less-than becomes &lt;, a greater-than becomes &gt;, a double quote becomes &quot;, and a single quote becomes &apos;. This keeps the output well-formed even when a value contains markup. When you convert the XML back to JSON, the browser decodes these entities, so the round trip returns the original text.
Does converting XML to JSON keep numbers and booleans as numbers?
No. XML has no built-in types: every value is text. When the tool reads XML, it keeps each element value as a string, so a count element holding 2 becomes the string "2", not the number 2. This is deliberate, because coercing text to numbers is ambiguous for values like a leading-zero code or a version string. Cast the strings yourself afterward if your program needs real numbers.
Why does my XML fail to convert to JSON?
The browser DOMParser found a syntax problem, so the tool shows the parser message instead of guessing. Common causes are a start tag with no matching end tag, tags closed in the wrong order such as <a><b></a>, an unquoted attribute value, a bare less-than or ampersand that should be escaped, or more than one root element. Fix the reported issue and convert again.
Is the data I paste uploaded anywhere?
No. Both directions run entirely in your browser: JSON to XML uses the built-in JSON parser and a small hand-written serializer, and XML to JSON uses the built-in DOMParser. Nothing is sent to a server, so you can paste private data without it leaving your machine. Open DevTools and watch the Network tab during a conversion to confirm there are zero requests.

Embed this tool

Free for any use; attribution appreciated. Paste this on your site:

The embed runs the same tool that lives at this URL. No tracking; no ads inside the embed. Resize height as needed for your layout.

Cite this tool

For academic, journalistic, or technical references. Pick a format:

Citations use 2026 as the publication year. Access date is left as a fillable placeholder where the citation style expects one.

Embedded tool from glunty.com