Skip to content
Toolew.com

XML to JSON Converter

Convert XML, RSS, SVG or SOAP responses to JSON with attributes, CDATA, namespaces and array handling you control.

Runs in your browser. Your data is not uploaded.
Loading tool…

This guide is not yet available in your language and is shown in English.

Tool guide

What this tool does

XML to JSON Converter validates XML and turns it into JSON using clear conventions: attributes become prefixed keys, repeated elements become arrays and mixed text goes into a #text key. Options cover namespace prefixes, CDATA, comments, type conversion and always-array output, and well-formedness errors show the exact line and column.

JSON is far easier to work with in JavaScript, Python and most APIs than XML, yet feeds, SOAP services, sitemaps, SVG files and many enterprise exports are still XML. Converting by hand is error-prone because XML has attributes, namespaces, CDATA sections and repeated elements that have no direct JSON equivalent, and a single unclosed tag makes the whole document invalid.

This tool first checks that the XML is well-formed and, if it is not, reports the line and column of the problem, such as a closing tag that does not match. It then converts with fast-xml-parser, loaded on demand. Attributes become keys with a prefix you choose, elements that appear more than once become arrays, and text inside an element that also has attributes goes under #text. Numbers and booleans can be typed while values with leading zeros, like barcodes, stay strings. Conversion runs locally in your browser.

How to use XML to JSON Converter

  1. Paste XML into XML input, open a file such as .xml, .rss, .gpx or .svg, or click Sample.
  2. Decide whether to Include attributes and which Attribute key prefix to use, or group them under one key.
  3. Choose whether to Convert numbers and booleans, and how Arrays are produced.
  4. Optionally remove namespace prefixes, keep CDATA separate, keep comments or keep the XML declaration.
  5. If an error is shown, fix the reported line and column; the output updates as you type.
  6. Copy or download data.json, or convert several XML files at once.

Tips for better results

  • Choose Always use arrays for child elements when code must handle one or many items the same way; otherwise a single <tag> becomes an object and two become an array.
  • Remove namespace prefixes to turn soap:Envelope and g:price into simpler keys, but only if no two namespaces use the same local name.
  • Entities such as &amp; and named HTML entities are decoded in text and attribute values.
  • Use JSONPath Tester on the result to pull out the fields you need.

Common use cases

  • Reading an RSS or Atom feed into a JavaScript app.
  • Inspecting a SOAP API response while writing an integration.
  • Converting GPX tracks or KML placemarks for a mapping library.
  • Migrating XML configuration files into a JSON-based system.

Common mistakes to avoid

  • Relying on a field being an object when it is sometimes repeated; use the always-array option or normalise in code.
  • Assuming element order survives; JSON objects do not keep mixed sibling order for different element names, so document-style XML with interleaved text is better processed as XML.
  • Pasting HTML and expecting it to parse; HTML is not XML unless every tag is closed, as in XHTML.

Frequently asked questions

How are XML attributes represented?

Each attribute becomes a key on the element’s object with the prefix you choose, for example @id. You can also group all attributes under a single @attributes key or leave them out entirely.

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

By default an element is an array only when it occurs more than once under the same parent. Switch Arrays to Always use arrays for child elements for a predictable shape.

What happens to CDATA sections?

By default CDATA content is merged into the element text. With Keep CDATA sections separate, it is placed under a #cdata key so you can tell it apart from ordinary text.

Does the converter validate against an XML Schema or DTD?

It checks that the XML is well-formed, meaning tags are properly nested and closed and attributes are quoted. It does not validate against an XSD or DTD.

Feedback & suggestions

Help us improve XML to JSON Converter. We read every message.

Rating (optional)
Necessary
Required for security, language and theme preferences. Always on.