Free XML to JSON Converter

Convert XML to JSON instantly. Handles attributes, nested elements, and text nodes. Runs entirely in your browser.

Your data never leaves your device
Drop XML file here or click to browse (max 5 MB)

What is XML?

XML (Extensible Markup Language) is a format for storing and transporting data. It uses custom tags to describe data structure, making it human-readable and widely supported. Unlike JSON, XML can include attributes on elements.

Why Convert XML to JSON?

Frequently Asked Questions

How are XML attributes handled?

XML attributes are converted to JSON properties with an @ prefix (e.g., @id, @href). This preserves attribute information in the JSON structure.

What about namespaces?

Namespaces are preserved in the output. Prefixes are included in the element names (e.g., "ns:element").

Can I convert JSON back to XML?

This tool converts XML to JSON. For the reverse, you can use our JSON to XML converter.

Two formats, three decades apart

XML 1.0 became a W3C Recommendation on 10 February 1998. The original editors were Tim Bray (Textuality / Netscape), Jean Paoli (Microsoft) and C. M. Sperberg-McQueen (University of Illinois at Chicago); the Working Group was chaired by Jon Bosak of Sun Microsystems. XML's lineage runs back to SGML (ISO 8879:1986), the document-markup standard that itself grew from IBM's GML in the 1970s. SGML was powerful but daunting; XML's design brief was "design a 'lite' version of SGML", trimming optional features to a profile that could be implemented in a few thousand lines of code while preserving Unicode, namespaces and attribute-rich documents.

JSON (JavaScript Object Notation) was discovered, not designed. Douglas Crockford and Chip Morningstar sent the first JSON message in April 2001 at State Software, deriving the format from JavaScript's object-literal syntax. Crockford registered json.org in 2002 and put up a one-page spec. The format was first formalised as RFC 4627 in July 2006, re-issued as RFC 7159 in 2014, and stabilised as RFC 8259 / STD 90 in December 2017, the same year ECMA-International published ECMA-404. JSON's design intent (per Crockford's retrospective): minimal, language-independent, easy to generate and parse, no version number ("there is no version number"), and deliberately no comments ("I removed comments because I saw people were using them to hold parsing directives").

JSON took over web APIs in the late 2000s as REST replaced SOAP and as XMLHttpRequest gave way to JSON-over-fetch. By 2015 JSON was the default response format of nearly every public API; XML survived in long-tail enterprise SOA, document formats (Office Open XML, OpenDocument), and standards-bound niches.

Where XML and JSON differ

XMLJSON
AttributesFirst-class (<item id="5"/>)No attributes, everything is a key/value pair
NamespacesNative (xmlns:prefix="uri")Flat names; prefix collisions are the app's problem
Comments<!-- … -->None per spec
Mixed contentNative (<p>text <b>and</b> markup</p>)Awkward, needs arrays or stringification
SchemaDTD, XSD 1.0 (2001) / 1.1 (2012), RELAX NG, SchematronJSON Schema (community spec, draft 2020-12)
OrderElement order is significant per specObject key order not guaranteed (most parsers preserve insertion order in practice); arrays are ordered
NumbersStrings until typed by schemaIEEE 754 double; no integer/float distinction at spec level
VerbosityHigh (every value wrapped in tagsLow) punctuation only

Why XML→JSON is fundamentally lossy

There is no W3C-blessed canonical mapping from XML to JSON. Every converter has to invent answers to questions XML allows you to express but JSON has no native vocabulary for. The recurring decisions:

When you'd reach for this

Modern alternatives

More questions

Why does the same XML produce a different JSON shape on different tools?

Because there is no canonical XML→JSON mapping. Each converter picks a convention (BadgerFish, Parker, JsonML, GData-style) and the resulting JSON shapes differ in how attributes are marked, how mixed content is preserved, and how repeated children are arrayed. Round-tripping XML through different converters produces different JSON; round-tripping JSON back to XML through different converters can change attribute placement and even element ordering. For interoperability, document the convention you're using and stick to it.

What about CDATA, comments and processing instructions?

CDATA sections (<![CDATA[…]]>) are flattened to plain string content, the wrapper is gone, but the text inside is preserved verbatim. XML comments (<!-- … -->) and processing instructions (<?xml-stylesheet …?>) are dropped, since JSON has no syntax for either. If you need round-trip fidelity that preserves comments, an XML-only round trip is the right approach.

Will my XML schema (XSD) survive the conversion?

No. XSD describes XML structure and types; JSON Schema is the analogous (separate) standard for JSON. Some advanced tooling can translate XSD to JSON Schema, but it's a lossy operation, XSD has features (mixed content, substitution groups, derived types) that have no clean JSON Schema equivalent. For document validation that matters, run XSD against the original XML, not against the JSON conversion.

Why did JSON win for web APIs?

A few reasons. JSON maps directly to JavaScript objects, so browser-side parsing is one JSON.parse() call away. The format is much smaller, no closing tags, no namespace declarations, no schema baggage. REST replaced SOAP for most public APIs in the late 2000s, and JSON was the natural payload for REST. XML's strengths (strict schemas, namespaces, mixed content) matter for documents and legacy enterprise systems but rarely for "give me the user object." The web optimised for the simpler case.

Does anything get sent to a server?

No. The XML is parsed by the browser's native DOMParser, then walked recursively in JavaScript to build the JSON output. Pasted XML never leaves the page. The tool works offline once it's loaded, which matters when the source XML contains internal API endpoints, customer data, or proprietary schemas you'd prefer not to upload anywhere.

Related Tools