About the JSON to XML Converter

What does this tool do?

JSON is what most modern apps and APIs speak, but plenty of systems — enterprise services, SOAP endpoints, RSS feeds, Office and Android files — still expect XML. This converter takes a block of JSON and rewrites it as well-formed XML: objects become nested elements, arrays become repeated tags, and the values land exactly where they belong. Paste your JSON on the left and the XML appears on the right the moment the input is valid.

You stay in control of the shape. Choose which JSON keys become XML attributes rather than child elements, set the name of the root element, decide whether to include the <?xml?> declaration, and pick the indentation. It runs entirely on your own machine — there's no upload and no third-party library involved — so it's fast, private, and works offline once the page has loaded.

How to Use This Tool

  1. Add your JSON. Type or paste it into the left editor, drag and drop a .json file onto it, or use Open file. Click Example to load a sample and see the output shape.
  2. Set the options. Pick the attribute-key prefix (keys like @_id become id="…"), name the root element used when wrapping is needed, toggle the XML declaration, and choose tabs, spaces, or minified output.
  3. Read the result. Valid JSON converts instantly and the XML shows on the right. If the JSON is malformed, the status badge shows the parser's message so you can fix it.
  4. Take the XML. Copy it to your clipboard or download it as a .xml file.

Common Use Cases

Going from JSON back to XML is a regular chore whenever new code has to talk to older systems:

  • Feeding a legacy or SOAP service: Turn a JSON payload into the XML body an older API or enterprise system requires.
  • Generating config or data files: Produce an XML config, a manifest, or an Android strings.xml from data you already hold as JSON.
  • Building feeds and sitemaps: Shape JSON data into the XML structure an RSS reader or a search engine expects.
  • Round-tripping: Convert XML to JSON with our companion tool, edit it as JSON, then bring it back to XML here.
  • Creating test fixtures: Quickly mint sample XML documents from JSON for unit tests or mock responses.

Need the opposite direction? Use our XML to JSON Converter, tidy JSON in the JSON Viewer, or inspect markup in the XML Viewer.

Frequently Asked Questions

How do I make a JSON key become an XML attribute?

Give the key a prefix and tell the converter which prefix you're using. By default, any key that starts with @_ — like "@_id": "b1" — becomes an attribute (id="b1") on its parent element instead of a child tag. You can switch the prefix to @ or $, or choose "No attributes" to turn every key into an element. A key named #text becomes the element's text content.

Why is there a "root element" option?

Every XML document needs exactly one top-level element. If your JSON already has a single top-level key, that key becomes the root automatically. But if it has several keys, or starts as an array or a plain value, there's no single name to use — so the converter wraps everything in a root element, and this setting lets you name it (it defaults to root).

How are arrays converted?

A JSON array becomes a set of repeated elements that share the array's key name. So "book": [ {…}, {…} ] produces two <book> elements side by side. That's the natural XML equivalent, and it's exactly what our XML to JSON converter turns back into an array.

Does it produce valid, well-formed XML?

Yes. Special characters in your values — &, <, >, and quotes in attributes — are escaped automatically, and key names that aren't legal XML tag names (for example, ones with spaces) are adjusted so the output always parses. Everything is wrapped under a single root element.

My JSON shows an error — what's wrong?

The input has to be valid JSON. The usual slip-ups are a trailing comma after the last item, single quotes instead of double quotes around keys and strings, or a missing bracket or brace. The status badge shows the exact parser message, including roughly where it tripped, so you can correct it — the XML updates by itself once the JSON is valid.

Is my data sent anywhere?

No. The conversion runs entirely in your browser with JavaScript. Nothing you paste is uploaded, stored, or logged, so the tool is safe for private or internal data and keeps working even without a connection.