RevealTheme logo

JSON to XML Converter

Paste JSON and get indented XML back. Object keys become element names, nested objects become nested elements, and array items repeat their parent key as the tag. Runs entirely in your browser.

How to use this tool

  1. 1

    Paste or type your JSON into the input box.

  2. 2

    If the JSON is valid, the converted XML appears below automatically as you type.

  3. 3

    Read any red error message if the parser rejects your input, then fix the JSON and try again.

  4. 4

    Select the generated XML from the output panel and copy it into your file or request body.

How does this JSON to XML converter actually work?

This is a lightweight, in-browser converter, not a full XML data-binding engine. It calls JSON.parse() on your text and then walks the resulting value recursively, emitting a fixed <?xml version='1.0' encoding='UTF-8'?> declaration followed by indented elements (two spaces per level). The mapping is deliberately simple: each object key becomes an element name, nested objects nest as child elements, and a string, number, or boolean becomes the text inside its element. Arrays are flattened, meaning every item is emitted with the same tag (its parent key), so {'items':[1,2]} produces two separate <items> elements rather than a wrapping list element. A top-level array uses the literal tag <root> for each item, and null or undefined values become self-closing <tag /> elements. Only the characters &, <, and > are escaped in text content; quotes and other characters are left as-is. Because JSON has no concept of attributes or namespaces, the output uses elements exclusively, and key names are sanitized by replacing any character outside a-z, A-Z, 0-9, and underscore with an underscore. The conversion happens locally in JavaScript, so nothing is sent to a server.

Common use cases

  • Drafting a quick XML sample from a JSON API response to test a legacy SOAP or XML-based endpoint.

  • Generating starter XML element structures so you do not have to hand-type deeply nested tags.

  • Eyeballing how a JSON config would map to an element tree before writing a proper transform.

  • Producing small XML fixtures for unit tests when your source data already lives as JSON.

  • Teaching or demonstrating the structural differences between JSON objects, arrays, and XML elements.

  • Converting flat configuration JSON into readable, indented XML for documentation snippets.

Frequently asked questions

Is my JSON uploaded anywhere?
No. The conversion runs completely in your browser using JavaScript's JSON.parse and local string building. Your data never leaves your device or hits a server.
How are arrays handled?
Each array item is emitted with the parent key as its tag, with no wrapping element. So {'tags':['a','b']} becomes two sibling <tags> elements, not a <tags> container holding two children. A top-level array repeats the literal tag <root> for each item.
Can it produce XML attributes?
No. JSON has no way to mark a value as an attribute versus a child, so every key becomes a child element. If you need attribute-based XML, you will have to add the attributes by hand or use a dedicated library.
Does it support namespaces, CDATA, or a schema?
No. The tool emits plain elements with a fixed UTF-8 declaration. It does not add namespace prefixes, CDATA sections, processing instructions, or validate against any XSD or DTD.
Why did one of my keys get underscores in it?
Element names are sanitized: any character that is not a letter, digit, or underscore is replaced with an underscore so the tag is syntactically usable. Note that keys starting with a digit are not renamed, which can still yield a technically invalid XML element name.
Which characters get escaped in the text?
Only the three markup-significant characters &, <, and > are escaped in element text. Quotes are left untouched, which is fine for element content but would matter if you later move values into attributes.
Should I use this for production-grade conversion?
Treat it as a fast drafting aid. For round-trip fidelity, attributes, namespaces, or strict validity, use a real library such as xml-js, fast-xml-parser, or a server-side XSLT/JAXB pipeline.

Related tools