Overview / Developer & Code / XML ↔ JSON Converter
Developer & Code 100% In-Browser & Offline

XML ↔ JSON Converter

Convert XML to JSON and JSON to XML in your browser. Attributes, repeated elements, CDATA and text are mapped, and errors show the line and column.

Paste or type your input; results appear instantly and errors are shown below the input. Fields start with an example: click one and just type to replace it.

Your files and input never leave your browser – nothing is uploaded.

Options

Attributes become keys starting with @, text next to attributes or elements goes to #text, and repeated elements become an array. In the other direction a single top-level key is the root; anything else is wrapped in the root element name.

Two formats, one mapping

XML has attributes, repeated elements, text and order; JSON has objects, arrays and values. There is no single official way to translate between them, so this converter uses one clear convention and applies it in both directions. Paste XML to get JSON, switch direction to turn JSON back into XML.

Convert in five steps

  1. Choose XML → JSON or JSON → XML.
  2. Paste your data into the left box. An example library catalog is there to show the mapping.
  3. Set the options: indentation, whether attributes are kept, and whether numbers and true/false are converted from text.
  4. Read the result on the right. If the input is invalid, the message names the problem with the line and column.
  5. Copy the result or download it as a file.

The mapping rules

  • An attribute becomes a key that starts with @: <book id="1"> gives "@id": "1".
  • An element with only text becomes a string. When it also has attributes or children, the text goes into "#text".
  • Elements that repeat under the same parent become an array. A list with only one entry stays a single object, so check such cases.
  • An empty element becomes an empty string in JSON, and null in JSON becomes an empty element in XML.
  • CDATA is read as text. Comments and processing instructions are dropped, because JSON has no place for them.

What does not survive the trip

JSON objects have no guaranteed order of attributes and elements are grouped by name, so an XML document that interleaves different elements loses that interleaving. Text mixed between elements, as in a paragraph with a bold word, is joined into one #text value. Data-style XML such as feeds, configuration and API responses converts cleanly; document-style XML such as articles does not.

Nothing is uploaded

The conversion runs in your browser. Feeds, exports and responses you paste are not sent anywhere.

Frequently asked questions (FAQ)

Choose XML → JSON and paste the XML. Attributes become keys with @, repeated elements become arrays and the JSON appears on the right.