XML to JSON Converter

Convert XML into readable JSON.

Developer Tools Free, no sign-up Runs in your browser

XML to JSON Converter tool

0
Elements
0
Attributes
0
Depth

About the XML to JSON Converter

XML to JSON Converter parses an XML document with your browser's own XML parser and rewrites it as JSON. It is the conversion you need when something upstream still speaks XML and everything you are writing speaks JSON.

XML carries information JSON has no direct equivalent for, so the output follows a convention rather than inventing one. Attributes are collected under an @attributes key, element text goes into #text when the element also has attributes or children, and repeated sibling elements become an array. That convention is widely used, predictable, and reversible.

Validation comes first. The document is parsed strictly before anything is converted, so a missing closing tag or a stray ampersand produces a clear message naming the line rather than half-converted output. XML is unforgiving by design, and a converter that papers over that is worse than useless.

Namespaces, CDATA sections, comments and processing instructions are all handled rather than discarded or mangled.

Everything runs inside your browser. Nothing you paste is uploaded, logged or stored, which matters when the input is a client list, an internal URL map or anything else you would not post publicly.

How to use the XML to JSON Converter

  1. Paste your XMLA full document or a fragment; it is parsed strictly either way.
  2. Choose how attributes are handledGrouped under @attributes, or merged into the object.
  3. Read any error carefullyInvalid XML is reported with the line and the reason.
  4. Copy or download the JSONIndented and ready to use.

Features

  • Parses with the browser's own strict XML parser
  • Attributes preserved under a predictable key
  • Repeated elements become arrays automatically
  • CDATA, comments and namespaces handled
  • Clear errors naming the line and the problem
  • Configurable indentation
  • Runs entirely in your browser

Who uses this tool

The xml to json converter is used by writers, developers, students, marketers and anyone else who needs the job done once without installing software. Common cases include:

  • Consuming an XML API from JavaScript
  • Converting an RSS or sitemap file for processing
  • Migrating configuration from XML to JSON
  • Inspecting an unfamiliar XML document in a friendlier shape
  • Preparing XML data for a tool that only reads JSON

Frequently asked questions

How are attributes represented?

Under an @attributes key on the element's object by default, which keeps them clearly separate from child elements. You can also merge them in directly if your consumer prefers that.

What happens to repeated elements?

They become an array. A single occurrence produces a plain object, which is the usual convention, so check for both shapes if the number of elements can vary.

What if my XML is invalid?

You get a clear error naming the line and the problem, and no output. XML is strict by design and silently guessing would hide the fault rather than fix it.

Are namespaces kept?

Yes. Prefixed names are preserved as they appear, so xsi:type stays xsi:type.

Is CDATA handled?

Yes. CDATA content becomes ordinary text in the JSON, which is what it represents.

Is my document uploaded?

No. Parsing and conversion both happen in your browser.

If the xml to json converter is not quite what you need, these other free tools solve closely related problems.

JSON to XML Converter

Turn JSON into indented, well-formed XML with proper escaping.

Developer Tools Use tool

XML Formatter

Pretty-print XML with proper indentation, and catch malformed documents.

Code Formatters Use tool

JSON Formatter

Pretty-print and validate JSON, with the exact line and column of any error.

Developer Tools Use tool

YAML to JSON Converter

Translate between YAML and JSON, with clear errors on invalid indentation.

Developer Tools Use tool

CSV to JSON Converter

Turn spreadsheet data into JSON, or JSON records back into CSV rows.

Developer Tools Use tool