P
Privatool

JSON to XML Converter Online Free — Convert JSON ↔ XML

Convert JSON to XML and XML to JSON instantly in your browser. Supports nested objects, arrays, XML attributes (via @ prefix), custom root element names, and configurable indentation. Paste text or upload a file. Download the result as .xml or .json.

100% private. All conversion runs locally in your browser. No data is uploaded or stored.

Loading converter…

How to Use the JSON to XML Converter

  1. 01

    Choose direction

    Select JSON → XML or XML → JSON. You can also swap input/output to reverse-convert your result.

  2. 02

    Paste or upload

    Paste your JSON or XML in the input panel, or upload a .json or .xml file. Click "Sample" to load an example.

  3. 03

    Copy or download

    The output updates as you type. Copy to clipboard or download as a .json or .xml file.

Frequently Asked Questions

How does JSON to XML conversion work?

Each JSON key becomes an XML element tag. String, number, and boolean values become the text content of that element. Nested objects become nested elements. Arrays are expanded as repeated elements with the same tag name. Keys starting with "@" are treated as XML attributes rather than child elements.

How are JSON arrays converted to XML?

JSON arrays are converted to repeated XML elements with the same tag name. For example, {"colors": ["red", "blue"]} becomes <colors>red</colors><colors>blue</colors>. When converting back from XML to JSON, elements with the same tag name are automatically grouped into arrays.

How do I set XML attributes when converting from JSON?

Keys that start with "@" become XML attributes. For example, {"book": {"@id": "1", "title": "Gatsby"}} converts to <book id="1"><title>Gatsby</title></book>. This convention is used by many JSON-XML libraries and is the default behavior of this converter.

What is the root element and why is it needed?

XML documents must have a single root element that wraps all content. JSON objects do not have this requirement. When converting JSON to XML, you specify a root element name (default: "root") that wraps the converted content. For example, {"name": "Alice"} becomes <root><name>Alice</name></root>.

Why might my XML to JSON conversion lose some information?

XML and JSON are not perfectly equivalent formats. XML supports mixed content (text and elements together), processing instructions, comments, and namespaces that have no direct JSON equivalent. This converter handles the most common patterns. For complex XML with namespaces or mixed content, manual review of the output is recommended.

What XML parse errors should I watch for?

Common XML errors: unclosed tags (every opening tag needs a closing tag), invalid characters in tag names (must start with a letter or underscore), unescaped special characters in text content (use &amp; for &, &lt; for <, &gt; for >, &quot; for ", &apos; for '). The converter shows the error message to help you identify and fix the issue.

Related Tools