JSON to XML Converter

JSON to XML conversion maps object keys to element names, string/number values to text content, and arrays to repeated elements. Use @-prefixed keys for XML attributes (e.g., "@id": "1" becomes id="1") and #text for mixed content. Null values become self-closing tags. The root JSON object should have a single key to serve as the XML root element.

Convert JSON to well-formed XML instantly. Keys starting with @ become attributes, #text becomes element text content, arrays become repeated elements. Configurable indentation, optional XML declaration. Presets for API responses, configs, and sitemaps. Free, private, no data sent to any server.

Works OfflineDark ModeNo Ads

JSON Input

XML Output

0 lines

Quick Examples

JSON to XML Conversion Rules

JSONXMLNotes
{"key": "value"}<key>value</key>Object keys become element names
{"@attr": "val"}attr="val"Keys starting with @ become attributes
{"#text": "val"}<tag>val</tag>#text becomes element text content
{"tag": [...]}Multiple <tag> elementsArrays become repeated elements
null<tag />Null values become self-closing tags

How to Use

  1. 1

    Paste your JSON

    Paste or type valid JSON into the input area — the tool converts it to XML automatically

  2. 2

    View the XML output

    The converter generates well-formed XML with proper indentation, attributes, and element structure

  3. 3

    Configure options

    Choose indent size (2 or 4 spaces) and toggle the XML declaration on or off

  4. 4

    Try a preset

    Click a quick example like Sitemap or API Response to see the conversion

  5. 5

    Copy the result

    Click the copy button to copy the XML output to your clipboard

Frequently Asked Questions

How do I convert JSON to XML?
Paste valid JSON into the input area and the tool generates well-formed XML instantly. Object keys become element names, string/number/boolean values become text content, and arrays become repeated elements.
How do I add XML attributes from JSON?
Prefix the JSON key with @. For example, {"book": {"@id": "1", "title": "My Book"}} produces <book id="1"><title>My Book</title></book>. The @ prefix signals that the key should be an attribute, not a child element.
How do I add text content alongside attributes?
Use the special key #text for element text content. For example, {"title": {"@lang": "en", "#text": "Hello"}} produces <title lang="en">Hello</title>. This lets you combine attributes and text on the same element.
How are JSON arrays converted to XML?
Each array item becomes a separate XML element with the same tag name. For example, {"item": ["apple", "banana"]} becomes <item>apple</item><item>banana</item>. This matches the standard XML convention for repeated elements.
Can I toggle the XML declaration?
Yes. Use the XML declaration checkbox to include or exclude the <?xml version="1.0" encoding="UTF-8"?> header. It is included by default. Disable it if you only need the XML body.
Is my JSON data sent to a server?
No. All conversion runs entirely in your browser using JavaScript. No data is transmitted to any server. The tool works offline once the page is loaded.

Related Tools