Convert JSON to XML

Turn JSON files into XML. Objects become elements inside one root element and every value becomes text, with characters a tag name cannot hold turned into underscores.

Converted in an isolated sandbox on our serversDeleted after 24 hours

Drop JSON files on the dialor turn it to pick what to do

JSON data as an XML document.Objects become elements inside one root element. Every value becomes text.

  1. What you get

    One XML file. The JSON objects become elements inside a single root element, and each value is written as the text of its element.

    A list repeats its element, once for each item. Keys that hold characters a tag name cannot use have those characters turned into underscores.

  2. Attributes and text

    A key that starts with @ becomes an attribute on its element. If the value is a list or an object, the attribute holds it written as JSON text.

    A key named #text becomes the element's own text.

  3. What changes

    Every value becomes text, so the XML does not record whether a value was a number, a boolean or a string.

    An empty list disappears, because a list is written by repeating its element and there are no items to repeat. A list of lists is flattened into one run of repeated elements.

  4. Failures

    The conversion stops with input_corrupted when the file could not be parsed. Check that the input is JSON before you convert it.

    To go the other way, use XML to JSON.

JSON and XML.What each format is.

The formats

From · JSON

JSON

JSON, the data format of every API.

Extensions
.json
MIME type
application/json
Kind
Text and data
To · XML

XML

XML documents and data.

Extensions
.xml
MIME type
application/xml
Kind
Text and data

In your code.The same JSON to XML conversion through the API, for your app or your agent.

terminal
$ cv convert report.json report.xml
$ cv convert report.json report.xml

Questions.What people ask about JSON to XML.

01OF 04

Objects become elements inside one root element. Each value becomes the text of its element.

Start the key with @. The key becomes an attribute, and a list or an object value is written in it as JSON text.

It disappears from the XML. A list is written by repeating its element, so an empty list leaves nothing to write.

The file could not be parsed. The conversion stops there and produces no XML.

More conversions.Other ways in and out of JSON and XML.