Skip to content
XML → JSONDeveloper tools

XML to JSON Converter

Convert XML to JSON with attributes, repeated tags, CDATA and namespaces kept. Choose names, types and arrays, and see errors with line numbers.

Did this tool work for you?

About this tool

About XML to JSON Converter

XML to JSON Converter turns XML into JSON without losing data. Paste XML or open a file and the JSON appears as you type. Attributes are kept: an attribute named id becomes @id, and you can choose another mark in front of the name, such as an underscore, or leave attributes out. When a tag has both attributes and text, the text is stored under #text. Tags that appear more than once in the same place become an array, in the order they were written. CDATA sections keep their text exactly, including signs that would otherwise be read as tags. Comments and processing instructions are not data and are left out. Because XML holds only text, you can choose whether numbers, true and false become real JSON values. This is done only when nothing would be lost: a PIN code such as 0248001 keeps its zero, 1.50 stays text because the last zero would disappear, and numbers of more than 15 digits stay text because JavaScript cannot hold them exactly. Always use arrays makes every tag an array, so that code reading the result does not have to handle one item differently from several. Remove namespace prefixes turns soap:Body into Body. Empty tags can become null, an empty text or an empty object. If the XML is not well formed, the message names the line and column and says what is wrong, for example a closing tag that does not match. The result can be indented with two or four spaces or a tab, or written on one line, and you can copy it or download a .json file. One thing JSON cannot express is text mixed with tags in the middle of a sentence, as in documents: all the text is kept, but its position between the tags is not. The conversion happens in your browser with its own XML parser, files can be up to 5 MB, and nothing is uploaded.

XML to JSON Converter tool

When to convert XML to JSON

Old formats, new code

Old APIs

Read a SOAP or XML answer in JavaScript.

ExampleRemove namespace prefixes and use the Body.

Feeds and sitemaps

Turn RSS or a sitemap into data.

ExampleEvery item or url tag becomes one array entry.

Importing data

Load an XML export into a database that takes JSON.

ExampleOrders with several item tags become arrays.

Settings files

Compare an XML setting with a JSON one.

ExampleAttributes are easy to see with @.

Finding an error

Learn why a program rejects a file.

ExampleLine 2, column 7: a closing tag does not match.

Learning

See how the two formats compare.

ExampleChange the options and watch the result.

XML to JSON tips

Data you can rely on

One item or many

A tag that appears once is not an array. Turn on Always use arrays if your code expects one.

Check codes and IDs

If an ID must stay text in every row, turn off number values.

Same name twice

With no mark for attributes, an attribute and a tag of the same name share an array. Keep the @.

Look at the XML first

See the structure as a tree and find errors.

Open XML Viewer

Work with the JSON

Format, check and search the result.

Open JSON Formatter

Need a table?

Turn rows of CSV into JSON.

Open CSV to JSON
Built & tested by

HemantInsights

Senior Software Engineer · Developer of Toolyconvert

Hemant developed XML to JSON Converter and tests it on desktop and mobile with real files. He is a senior software engineer from Dehradun, India, building websites since 2014, and designed and developed Toolyconvert end to end.

Last updated 24 November 2026

Answers and guidanceFrequently Asked Questions
Are XML attributes kept?
Yes. They get an @ in front of the name by default. You can choose another mark or leave them out.
What is #text?
The text of a tag that also has attributes or child tags.
Why is one item not an array?
XML does not say whether a tag may repeat. Turn on Always use arrays to get an array every time.
Why is my number in quotes?
It would change as a JSON number, because of a leading zero, a last zero after the point, or more than 15 digits.
Does it support namespaces?
Yes. Prefixes are kept, or removed if you choose.
What happens to comments?
They are left out, as are processing instructions.
Is my XML uploaded?
No. It is converted in your browser.
More tools for your workflowRelated Tools

Featured on

Toolyconvert is listed on these product directories and launch platforms.