Free XML to JSON — no upload, no account

Convert XML to JSON
Attributes, namespaces,
CDATA — handled.

Free XML to JSON converter. Choose how to handle attributes, strip namespaces, force arrays for repeated elements. Uses the browser's native DOMParser — your XML never leaves your device.

Your data never leaves your browser
Attribute handling: ignore, @prefix, merge
Namespaces: strip or preserve
Force arrays for repeated elements
Always free
XML to JSON Converter   100% client-side
Conversion uses the browser's native DOMParser — no external library, no data upload.
XML input
  JSON ready

      
How to convert XML to JSON

Three steps — paste your XML and get clean JSON in seconds.

1
Paste or upload your XML

Paste XML text directly or upload a .xml file. The browser's native DOMParser validates and parses the structure instantly — syntax errors are reported with the line number so you can fix them before converting.

2
Choose attribute and output options

Decide how to handle XML attributes — prefix with @, ignore them, or merge into the object. Strip namespace prefixes for cleaner keys. Choose compact mode to turn text-only nodes into simple string values instead of nested objects.

3
Copy or download the JSON

Click Convert and copy to clipboard or download a .json file. The output is valid JSON ready for any API, JavaScript application, database or data pipeline that consumes JSON.

The XML to JSON mapping problem

Why there is no single correct way to convert XML to JSON.

XML and JSON have fundamentally different data models. XML elements can have both attributes and child content simultaneously — a concept that has no direct equivalent in JSON. An element like <user id="1">Alice</user> carries both an attribute (id) and text content (Alice) at the same time. There is no universally agreed mapping for this in JSON.

JSONshift offers two strategies. Compact mode prioritises readability: text-only elements become string values directly ({"name": "Alice"}), and attributes are prefixed with @ to distinguish them from child elements. Verbose mode preserves the full DOM structure — text content lives under a #text key — which is more verbose but fully reversible back to XML.

Namespace prefixes (like soap:Body or ns0:item) make JSON keys awkward and break dot-notation access in JavaScript. The strip option removes the prefix, producing clean keys like Body and item. Keep prefixes when the namespace is semantically meaningful and you need to distinguish between elements from different schemas.

When do you need XML to JSON?

Common workflows where JSON is more practical than XML.

REST APIs from SOAP services

Legacy SOAP and XML-RPC services return XML responses. Converting to JSON allows you to process the data with modern JavaScript, Python or Go tooling without an XML parsing library — and to pass the data to REST API consumers that expect JSON.

RSS and Atom feeds

RSS and Atom syndication feeds are XML. Converting to JSON lets you consume feed data in a JavaScript front-end, store it in a document database like MongoDB, or process it in a pandas DataFrame without the overhead of an XML parser dependency.

Configuration file migration

Many legacy applications use XML for configuration (Maven pom.xml, Spring XML, Ant build files). Converting to JSON is often the first step when migrating a project to a modern stack that uses JSON or YAML configuration.

Data exchange and ETL

EDI, healthcare (HL7, FHIR), financial (FpML, XBRL) and government data standards use XML. Converting to JSON is a common first step in ETL pipelines that feed modern databases, data lakes or analytics tools that prefer JSON input.

Conversion options explained

How each setting affects the JSON output structure.

OptionValuesWhat it does
Attributes @prefix · Ignore · Merge @prefix adds an @ before each attribute name — e.g. @id, @class — making attributes visually distinct from child elements. Ignore drops all attributes, producing the simplest possible output. Merge puts attributes and child elements in the same object without any prefix — shorter keys but potential name collisions.
Output mode Compact · Verbose Compact converts text-only nodes to plain string values — {"name":"Alice"} instead of {"name":{"#text":"Alice"}}. Verbose preserves the full DOM structure with explicit #text keys — larger output but fully reversible to XML.
Namespaces Strip · Keep Strip removes namespace prefixes from element and attribute names (soap:BodyBody). Produces cleaner JSON keys safe for dot-notation access. Keep preserves the prefix — necessary when elements from different namespaces share the same local name.
Repeated elements Always arrays · Mixed Always arrays wraps every element in an array, even when it appears only once — producing a consistent structure regardless of how many siblings exist. Mixed uses an object for single occurrences and an array for multiples — more compact but can cause type inconsistency if the XML is later extended with additional elements.
Formatting Pretty · Minified Pretty uses 2-space indentation for human readability. Minified removes all whitespace — smaller payload for API transmission or static assets.
Related JSON tools

Other free converters you might need next.

Popular searches
xml to json converter convert xml to json online xml to json free xml to json parser xml to json javascript convert xml file to json xml to json with attributes soap xml to json rss feed to json xml to json python xml to json namespace transform xml to json xml to json array

XML parsed by your
own browser. No upload.

The conversion uses the browser's native DOMParser — the same engine that renders every web page you visit. Your XML is parsed locally, the DOM is traversed in JavaScript, and the resulting JSON is built entirely in memory. Nothing leaves your device.

The converter handles real-world XML edge cases: CDATA sections, mixed content (text and child elements in the same node), empty elements, self-closing tags and deeply nested structures — all mapped correctly to their JSON equivalents.

Native DOMParser
No external library. Uses the browser's built-in XML parser — the fastest and most standards-compliant option available.
CDATA and mixed content
CDATA sections are extracted as plain text. Mixed content (text + child elements) is handled correctly in verbose mode.
Flexible attribute mapping
@prefix, ignore or merge — three strategies for the attribute-to-JSON mapping problem, covering every major use case.
47 tools, always free
No file size limits, no watermarks, no account. Funded by non-intrusive display advertising only.
Frequently asked questions
Common questions about converting XML to JSON online.
How do I convert XML to JSON?
Paste your XML or upload a .xml file into the converter above, choose your attribute and namespace options, then click Convert. Copy or download the JSON output instantly. The conversion uses the browser's native DOMParser — no upload required.
How are XML attributes handled in the JSON output?
Three options: @prefix adds @ before each attribute name (e.g. @id, @class) making them visually distinct from child elements. Ignore drops all attributes for the simplest output. Merge puts attributes and child elements in the same object — shorter keys but risks name collisions if an attribute and a child element share the same name.
How are repeated XML elements converted to JSON?
With "Always use arrays" enabled, elements that appear more than once at the same level are grouped into a JSON array — and single elements are also wrapped in arrays for consistency. Without this option, a single occurrence becomes an object and multiple occurrences become an array, which can cause type inconsistency when the XML is later extended.
What is the difference between compact and verbose output?
Compact mode converts text-only nodes to plain string values — {"name": "Alice"} instead of {"name": {"#text": "Alice"}}. This is more readable and is what most developers expect. Verbose mode preserves the full DOM structure including explicit #text keys — larger but fully reversible back to XML without data loss.
Is my XML data safe when using this converter?
Yes. The conversion uses the browser's native DOMParser — your XML never leaves your device. Open the Network inspector during conversion and you will see zero outbound data requests.
Is the XML to JSON converter free?
Yes, completely free. No file size limits, no account required. JSONshift is funded by non-intrusive display advertising.
Go up