JSON Input JSON
โš ๏ธ Invalid JSON โ€” please check your input.
XML Output XML
Advertisement
What does a JSON to XML converter do? A JSON to XML converter rewrites JSON data as XML elements. This one turns each key into a tag, repeats an array item tag for list entries, wraps everything in a root element you name, and escapes special characters. It runs in your browser and never sends your JSON anywhere.

What does a JSON to XML converter do?

JSON has objects, arrays and values. XML has elements, text and attributes. There is no single official way to map one onto the other, so every converter makes choices. This JSON to XML converter makes simple, predictable ones: each JSON key becomes an element, each array becomes a parent element with repeated children, and every value becomes element text.

Two fields control the shape. Root element is the outer tag (default root), because XML needs exactly one top-level element and JSON does not. Array item tag (default item) names the child elements inside an array, since a JSON array has no keys to use. A list like ["a","b"] under tags becomes <tags><item>a</item><item>b</item></tags>.

One honest limit: the tool never writes XML attributes. Everything becomes a child element, so if the receiving system expects <book id="1">, you will need to adjust the output or the target schema. Before converting, you can clean up messy input with the JSON formatter.

How to convert JSON to XML here

  1. Paste your JSON into the JSON Input box, or click Sample to load an example.
  2. Set Root element. If your JSON is a top-level object, its keys go inside this tag.
  3. Set Array item tag to the name you want for list entries, such as book or row.
  4. Tick or untick Pretty print, XML declaration and Wrap strings in CDATA.
  5. Click Convert. If the input is not valid JSON you will see a red warning instead of output.
  6. Use Copy for the clipboard or Download .xml to save output.xml.

Options in this JSON to XML converter

Named root and item tags

You choose both the outer element and the tag used for array entries, so the output can match the tag names your XML consumer expects.

Key sanitising

Keys with spaces or odd characters are rewritten with underscores. Keys that start with a digit or with "xml" get a leading underscore so the tag stays legal.

CDATA option

With Wrap strings in CDATA on, string values (and numbers and booleans too) go inside CDATA sections. A literal ]]> inside the text is split safely.

Null handling

A JSON null becomes <key xsi:nil="true"/>, and the xsi namespace is declared on the root only when a null is present.

Empty containers

An empty object or empty array turns into a self-closing tag such as <tags/>.

Compact or pretty output

Pretty print indents with two spaces. Switch it off for a single-line string, and line breaks inside your text values are kept.

When you need JSON as XML

  • Feeding a legacy SOAP or enterprise endpoint. Your app produces JSON but an older service wants XML. Convert a sample payload, then adjust the root and item names to match the service.
  • Building a quick RSS-style or sitemap-style draft. Turn a list of records into repeated item elements to see the shape. Expect to add attributes and namespaces by hand.
  • Test fixtures. QA engineers can generate an XML version of an API response to test a parser without writing it by hand.
  • Learning the difference between formats. Students can paste small objects and watch how arrays, nulls and nesting change when moved into XML.

Tips and gotchas before you convert

  • Wrap multi-record data in an array under a named key, for example {"books":[...]}, so each record gets a meaningful parent tag.
  • If the root of your JSON is an array, the converter puts it under your Root element and repeats the Array item tag inside.
  • Use CDATA only for text with markup or many ampersands. Plain escaping is easier to read for ordinary strings.
  • Numbers and booleans lose their type in XML. 30 and "30" produce the same output.
  • Check key names after converting. A key like first name becomes first_name.

Is it safe? Privacy and limits

The conversion is plain JavaScript running in your browser tab. Your JSON is parsed with JSON.parse and the XML is built locally, with no upload and no account. Closing the tab clears it. The tool does not validate against a schema or XSD, so treat the result as a draft and test it with the system that will consume it.

JSON to XML converter FAQ

Each array becomes an element named after its key, and every entry inside it becomes a child using the tag in the Array item tag field, which defaults to item. So {"tags":["a","b"]} gives a tags element holding two item elements. There is no way to give each entry a different tag. Arrays of objects work the same way: each object becomes one item element containing its own child elements. An empty array becomes a self-closing tag. If the whole document is an array, the Root element holds the items directly.

XML requires exactly one top-level element, while JSON can hold several keys side by side. The converter wraps your data in the tag typed in Root element, which defaults to root. Change it to something meaningful such as catalog or response. If your JSON is an object with a single key you want as the root, you can still wrap it, or delete the outer tag in the output. The tool does not guess a root name from your data.

No. Every JSON key becomes a child element and every value becomes element text. There is no convention such as an @id key that turns into an attribute. If your target format needs attributes, such as RSS or SVG, use this output as a skeleton and edit it, or move the data into attributes with your own script. The XML to YAML converter reads attributes, but this one does not write them.

They are rewritten. Characters other than letters, digits, underscore, dot and hyphen become underscores, so first name turns into first_name, and a key with an accent such as รฉ is kept as is. If the result starts with a digit or punctuation, or starts with the letters xml in any case, a leading underscore is added. An empty key becomes _key. This keeps the output well-formed, but it changes your data, so check the names if the receiver is strict about them.

Numbers and booleans are written as plain text, so 30 becomes <age>30</age> and true becomes <flag>true</flag>. XML has no types, so the receiver must know which fields are numeric. A null becomes an empty element with xsi:nil="true", and the converter adds the xmlns:xsi declaration to the root so the document stays valid. If you would rather drop nulls, remove them from the JSON first. If you need the reverse direction, convert XML with XML to YAML and read it from there.

Turn it on when string values contain markup or many special characters, for example an HTML snippet in a description field. CDATA lets the receiver read the text without un-escaping. Without it, characters such as less-than, greater-than, ampersand and quotes are escaped as entities. This tool wraps every scalar value when the box is ticked, including numbers, so it is not selective. Some parsers treat CDATA and escaped text the same, others do not, so test with yours. Check the markup in your sample with the HTML formatter first if it is messy.

There is no upload and no fixed limit in the code. You paste text into a box, and the practical limit is your browser's memory. A few megabytes of JSON converts quickly on a modern laptop, though the textarea may feel slow to scroll. For very large files, a command-line tool or a script is a better fit. You can save the result with Download .xml, which writes a file called output.xml.

No. The page parses and converts your text with JavaScript inside your browser. Nothing is posted anywhere, and there is no login. You can check this by loading the page, switching off your network connection, and converting again; it still works. Do not paste secrets into any web page you do not trust, though, and clear the box when you are done on a shared computer. If you need to encode data safely instead, a Base64 encoder is the usual tool.

The output is well-formed by construction, because tags are sanitised and text is escaped. It is not validated against any schema. To check it, open it in a browser, run it through an XML linter, or load it with the parser your application uses. If the consumer expects specific element order, attributes or namespaces, you will have to add those yourself. Also remember that pretty printing only affects whitespace between tags, so a valid compact document stays valid when you turn indentation back on.

Advertisement