Skip to converter
</> XML to JSON 100% Private

XML to JSON Free Online XML to JSON Converter

Last updated:

100% Free, Private & Instant XML to JSON Converter — Parse & Format Structured Data Online.

⚡ Live preview ✓ Syntax validation 🔒 No uploads 📦 Native DOMParser

Parser Settings

XML Attributes
Output Formatting
Normalization

Waiting for XML input

Paste XML, drop an .xml file, or load the sample to begin.

XML Input

0 lines · 0 B Drag & drop supported

JSON Output LIVE

{ }

Your JSON will appear here instantly.

Converted locally — nothing leaves your device.

0 B

Tip: press Ctrl + Shift + C to copy the JSON output.

Advertisement

How to Convert XML to JSON Online

XML to JSON turns any well-formed XML document into clean, structured JSON in milliseconds. It uses your browser's built-in DOMParser engine, so there are no frameworks to load and no files sent to a server.

  1. 01

    Add your XML

    Paste raw XML into the input pane, drag & drop an .xml file, or click “Load Sample XML”.

  2. 02

    Choose settings

    Pick how attributes are handled, whether repeated tags become arrays, and pretty print or minified output.

  3. 03

    Copy or download

    The JSON preview updates live. Copy it to your clipboard or download it as a .json file.

XML to JSON Mapping Rules

Because XML and JSON model data differently, XML to JSON follows predictable, widely used conventions:

Elements → keys

Each element becomes a JSON key named after its tag. Elements that contain only text become simple string values.

Attributes → @attributes

Attributes are grouped in an "@attributes" object, inlined as "@name" keys, or ignored — your choice.

Repeated tags → arrays

Siblings sharing a tag name are merged into a JSON array. “Force arrays” wraps every child for a consistent schema.

Mixed text → #text

When an element has attributes or children and text, the text is stored under "#text". CDATA becomes plain text.

Example

<book id="bk101" lang="en">
  <title>XML Developer's Guide</title>
  <tag>xml</tag>
  <tag>json</tag>
</book>
{
  "book": {
    "@attributes": { "id": "bk101", "lang": "en" },
    "title": "XML Developer's Guide",
    "tag": ["xml", "json"]
  }
}

Why Use XML to JSON?

Frequently Asked Questions

How do I convert XML to JSON online?

▾

Paste your XML into the left input pane or drag and drop an .xml file onto it. XML to JSON parses it instantly and shows the JSON in the right pane. Choose your attribute, array and indentation settings, then click Copy JSON or Download .json.

How are XML attributes represented in the resulting JSON?

▾

By default, attributes are grouped in an "@attributes" object inside the element — <book id="1"> becomes {"book": {"@attributes": {"id": "1"}}}. You can switch to @-prefixed keys ("@id": "1") or ignore attributes entirely. When an element has both attributes and text, the text is stored under "#text".

Is my XML data secure and private?

▾

Yes. The conversion runs 100% in your browser using the native DOMParser API. Your XML is never uploaded, stored or sent to any server, so it is safe to use with confidential or internal data.

How are repeated XML elements converted?

▾

Sibling elements with the same tag name are automatically grouped into a JSON array. Enable “Force arrays” to wrap every child element in an array, which gives a consistent structure that is easier to loop over in code.

What happens if my XML is invalid?

▾

XML to JSON validates your XML in real time. If a tag is malformed, mismatched or left unclosed, a red status banner shows the error message with its line and column number, the line is highlighted in the editor gutter, and you can jump straight to it.

Can I convert large XML files to JSON?

▾

Yes. Files of several megabytes convert in well under a second on modern devices. For very large outputs, syntax coloring is turned off automatically to keep the preview fast; copy and download still contain the full JSON.

Does XML to JSON support CDATA, namespaces and mixed content?

▾

Yes. CDATA sections are converted to plain text values, namespace prefixes are kept in key names (for example "dc:title"), and mixed text alongside child elements is stored under the "#text" key. Comments and processing instructions are skipped.

Are all the tools on FreeToolCabin tested for quality and accuracy?▾

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related Developer Tools

More free, private, browser-based utilities for working with data.

Pitfalls when moving data from XML to JSON

The conversion is predictable, but XML and JSON do not carry the same information. Watch for these issues before you use the output in code:

Typical jobs this converter handles

Round trips and related tools

Converting XML to JSON and back again rarely reproduces the original file byte for byte. Comments and processing instructions are skipped, the interleaved order of mixed siblings is lost, and a converter going the other way has to guess which keys were attributes and which were child elements. If you need XML again later, keep the original file. For the reverse direction, JSON to XML Converter builds XML from JSON. If the XML itself is hard to read, tidy it first with XML Formatter, and use JSON Formatter to validate or reformat the JSON you get.

More questions about XML to JSON

Why did my ZIP code lose its leading zero?

Type detection treats values that look like numbers as numbers, and numbers cannot keep leading zeros. Turn off Detect types so the value stays a string.

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

An element that appears once becomes an object, while repeated siblings become an array. Enable Force arrays to get the same structure every time.

Can I turn the JSON back into the exact original XML?

Usually not exactly. Comments, the order of mixed sibling elements and some formatting are lost, so keep the source XML if you need it later.

Does the converter handle HTML files?

Only if the HTML is well-formed XML, such as XHTML. Ordinary HTML with unclosed line break or image tags will be reported as invalid XML.