Free XML to JSON Converter Online

Convert XML to JSON online for free. Keep or drop attributes, pick the attribute prefix, convert numbers and booleans, and see XML errors by line.

  • No upload, 100% private
  • Instant, in your browser
  • 100% free, no signup
Loading tool…
Read the complete guideHow to Convert XML to JSON Without Losing Attributes or Arrays →

About the XML to JSON Converter tool

Plenty of data still arrives as XML: RSS and Atom feeds, SOAP responses, sitemaps, product feeds, invoices and configuration files. Modern JavaScript code and NoSQL databases prefer JSON, so converting XML is a frequent chore. This converter does it in your browser using the fast-xml-parser library.

Before converting, the XML is validated and any problem, such as a missing closing tag or an unescaped ampersand, is reported with its line and column. Elements become JSON keys, repeated sibling elements such as several <product> tags become arrays automatically, and text content is placed under #text when an element also has attributes. CDATA sections are unwrapped into plain strings and the XML declaration is dropped.

You decide how attributes are handled: include them or ignore them, and choose the prefix that marks them, @_ by default, or @, _ or none. With “Convert numbers & booleans” on, values like 24.99 and true become real JSON numbers and booleans; switch it off to keep every value as a string, which is safer for codes with leading zeros. Pick 2 spaces, 4 spaces or tabs for the output.

How to use XML to JSON Converter

  1. Paste XML into “XML input”, open an .xml, .rss or .svg file, or click “Load sample”.
  2. Choose whether to “Include attributes” and pick an “Attribute prefix”.
  3. Decide whether to “Convert numbers & booleans” and choose the “JSON indent”.
  4. Copy or download the “JSON output”, or fix any error shown with its line number.

Features

Validation with positions

Malformed XML is reported with line and column before conversion.

Attribute control

Keep or drop attributes and choose the prefix that distinguishes them from child elements.

Automatic arrays

Repeated elements with the same name become JSON arrays.

Typed values

Optionally convert numeric and boolean text into real JSON types.

When to use it

  • Turn an RSS feed into JSON for a static site generator.
  • Convert a SOAP or legacy API response for use in a JavaScript front end.
  • Transform a product feed XML into JSON for import into a NoSQL database.
  • Inspect the structure of an XML sitemap or config in a familiar format.

Frequently asked questions

How are XML attributes shown in JSON?

As keys with a prefix, @_ by default, so <price currency="USD">24.99</price> becomes {"@_currency": "USD", "#text": 24.99}. You can change or remove the prefix.

Why is a single element not an array?

The converter cannot know that an element may repeat when it appears only once, so a single <tag> becomes an object or value and two or more become an array. Normalise this in your code if needed.

Are namespaces supported?

Namespace prefixes are kept as part of the key, for example media:content, so no information is lost.

Can I convert JSON back to XML?

Yes, use the JSON to XML converter on this site.

Related tools