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.
- Free, no sign-up
- Nothing is sent to a server
- Worldwide
How to use XML to JSON Converter online
- Paste the XML. Type or paste the text.
- Choose options. Attributes, numbers and indent.
- Read the JSON. The result appears at once.
- 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?
How are repeated elements shown?
What is #text?
Does it check the XML?
What happens to XML comments?
Is the text I paste into the XML to JSON Converter uploaded?
How do I keep the result of the XML to JSON Converter?
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.