JSON to XML Converter

Turn JSON into well-formed XML, with attributes, repeated elements and an optional XML declaration.

Processed on your device. Files are not uploaded

How to convert JSON to XML

  1. Paste your JSON

    Paste or type it into the box, or press Try an example.

  2. Name the root

    Used when the JSON has no single top-level key.

  3. Set attributes and layout

    Keys that start with the attribute prefix, such as @id, become attributes. Choose the indentation and whether to add the XML declaration.

  4. Copy or download

    Save the output as a .xml file.

Worked example

This is what JSON to XML Converter gives for its own sample values. Open the tool above and change anything to try your own.

JSON

{
  "name": "sarva-tools",
  "version": "1.2.0",
  "private": true,
  "author": { "name": "Ada", "email": "ada@example.com" },
  "keywords": ["tools", "developer"],
  "scripts": { "build": "next build", "test": "vitest run" }
}
Root element name
root
Attribute prefix
@
Indentation
2 spaces
Add the XML declaration
Yes

XML

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <name>sarva-tools</name>
  <version>1.2.0</version>
  <private>true</private>
  <author>
    <name>Ada</name>
    <email>ada@example.com</email>
  </author>
  <keywords>tools</keywords>
  <keywords>developer</keywords>
  <scripts>
    <build>next build</build>
    <test>vitest run</test>
...

About JSON to XML Converter

Turn JSON into well-formed XML. Keys that start with the attribute prefix, such as "@id", become attributes, lists become repeated elements, and special characters are escaped.

FAQs

How do I write an attribute?

Start the key with the attribute prefix, which is @ by default, for example "@id": 7.

What if my JSON has several top-level keys?

They are wrapped in a root element, whose name you can set.

Can I convert XML back?

Use XML to JSON Converter.

Related tools