UtilityNest

XML to JSON

Convert XML documents such as RSS feeds, sitemaps, SOAP responses and API data into clean JSON. You control how attributes, text and repeated elements are mapped, and broken XML is pinpointed by line and column.

한국어로 보기
  • Files stay on your device
  • No sign-up
  • Free, no limits

Leading zeros stay strings.

soap:Body becomes Body.

How to use XML to JSON

  1. 1Paste XML into the box, or open or drop an .xml file.
  2. 2Choose how attributes are written: prefixed keys (default @), grouped in an @attributes object, or ignored.
  3. 3Choose the array rule (only repeated elements, or always) and the key used for text next to child elements.
  4. 4Optionally convert numbers and true/false, remove namespace prefixes and trim whitespace.
  5. 5Copy the JSON or download it. If the XML is invalid, fix the reported line and the JSON appears.

How XML maps to JSON

XML has features JSON does not have, so every converter has to make choices. Here they are yours:

  • Attributes: <price currency="USD"> becomes {"@currency": "USD"}. Change the prefix to _ or -, leave it empty, group attributes under @attributes, or drop them.
  • Text: an element with only text becomes a plain value. When an element has attributes or children as well as text, the text goes under #text, or any key you choose.
  • Arrays: by default only elements that repeat become arrays, which gives the most natural JSON. Choose Always if your code needs a consistent shape whether there is one <item> or many.
  • Types: numbers and true/false can be converted, and values with leading zeros stay strings.
  • Namespaces: soap:Body can become Body, and xmlns declarations are dropped.

CDATA sections are kept as text, character references like &#44032; are decoded, and comments and processing instructions are skipped.

Clear errors for broken XML

Instead of a generic parse error, you get the line and column and a plain explanation: a closing tag that does not match the tag opened on line 12, an attribute without quotes, a stray & that should be &amp;, an HTML entity like &nbsp; that XML does not know, a tag that is never closed, or a second root element. The faulty line is shown with a marker, and Show in editor jumps to the spot. The checks are the same in every browser because the parser is built into the page instead of relying on the browser's own XML parser.

Need to tidy the result? Paste it into the JSON Formatter. To turn it into a table, use JSON to CSV.

Frequently asked questions

How are XML attributes converted?

By default as keys starting with @, for example {"@id": "bk101"}. You can change the prefix, group them under @attributes, or ignore attributes completely.

Why is an element sometimes an object and sometimes an array?

With the default rule, an element becomes an array only when it appears more than once in the same parent. Choose Always under Arrays to make every element an array.

My XML will not convert. How do I find the error?

The error box shows the line, column and reason, and the faulty line with a marker. Click Show in editor to jump to that position in the input.

Are DTDs or external entities loaded?

No. DOCTYPE declarations are skipped and external entities are never fetched, so converting untrusted XML is safe.

Can it handle large XML files?

Yes. Large files are shown as a file card instead of in the text box and are parsed in a background thread. The output box shows the beginning, while Copy and Download include everything.