Menu
PDF Tools
Image Tools
Converters & Utilities
Seller & Print Tools
Accounting & Business
Calculators
Text & Writing Tools
Developer & Web Tools
Creator & Social Tools
Browser Utilities & Games
Document & Design Makers
Text & Developer Tools
Exam & Form Tools

XML to JSON Converter

This tool converts XML to JSON. Attributes are kept with a @ in front, repeated elements become lists, and text next to attributes goes in #text.

How to use XML to JSON Converter online

  1. Paste the XML. Type or paste the text.
  2. Choose options. Attributes, numbers and indent.
  3. Read the JSON. The result appears at once.
  4. Copy it. Copy or save the JSON.

Why use this free XML to JSON Converter

  • Attributes with @
  • Repeated elements as lists
  • Numbers option
  • Well-formedness check
  • Entities decoded
  • Share by link

How XML maps to JSON

An element becomes a key, and its content becomes the value. An element with only text becomes a string. An element with children becomes an object, and a child that appears more than once becomes a list. Attributes are written as keys that begin with @. Text mixed with children or attributes is stored under #text.

Checks first

The tool first checks that the XML is well-formed, with matching tags, one root, quoted attribute values and no stray ampersands. If not, it says what is wrong and where, and gives no result. Entities such as & in text and attributes are turned back into characters.

A worked example

The XML for a book with an id attribute, a title and two tag elements becomes this JSON:\n{ "book": { "@id": "7", "title": "Dune", "tag": [ "sf", "classic" ] } }\nThe id attribute is kept as @id, and the two tag elements become a list. Comments in the XML are dropped.

Options

Attributes can be left out if you only want the content. Numbers in the text can be turned into JSON numbers, which is handy for data, but leave it off if a value like 007 must stay as text. The indent can be 2 or 4 spaces, a tab or one line.

Limits

XML can hold things JSON cannot, such as the order of mixed text and elements, namespaces and processing instructions, so the result is a practical reading and not an exact copy. A one-item list in XML looks like a single value, so the tool cannot know it was meant as a list. Check the shape against what your code expects.

Using the tool

Change the text or any option of the XML to JSON Converter and the answer moves straight away. Find and replace is built into the editor with Ctrl+F and Ctrl+H.

XML to JSON Converter: frequently asked questions

How are attributes written in JSON?
As keys that begin with @.
How are repeated elements shown?
As a list.
What is #text?
Text that sits next to attributes or child elements.
Does it check the XML?
Yes. It must be well-formed, or the tool gives an error.
What happens to XML comments?
They are left out of the JSON.
Is the text I paste into the XML to JSON Converter uploaded?
The XML to JSON Converter works locally, and clearing the site data removes anything the editor saved.
How do I keep the result of the XML to JSON Converter?
Press Use result as input and the XML to JSON Converter answer becomes the new input.

Related searches for XML to JSON Converter

  • XML to JSON Converter online
  • free XML to JSON Converter
  • XML to JSON Converter online free
  • XML to JSON Converter for mobile
  • XML to JSON Converter without sign up
  • convert xml to json converter
  • xml to json converter converter
  • XML to JSON Converter – Text & Writing Tools

XML to JSON Converter is a free online tool on MAITBOX, in the Text & Writing Tools group. It runs in your browser, so what you type is not sent to a server. It works on Android and iPhone, and on Windows, Mac and Linux, with no download and no account.

More tools in Text & Writing Tools →

Search tools