Your files never leave your device. All processing happens locally in your browser.
How do I convert XML to JSON in the browser without uploading the file?
Open the XML to JSON Converter, then paste your XML, drop in an .xml / .json / .txt file, or fetch a CORS-enabled URL — and it converts to JSON live as you type, entirely in your browser using the built-in DOMParser. XML attributes become JSON keys marked with a chosen prefix (@ by default, or _ or $), so <book id=“7”> yields {“@id”:“7”}; repeated sibling elements with the same tag collapse into a JSON array; an element that mixes text with attributes or children keeps its text under a #text key (switchable to _text or $t); CDATA can be preserved under a #cdata key; and empty leaf elements become null. Optional passes coerce “42”, “true” and “null” into real numbers, booleans and null (round-trip safe, so IDs and leading zeros are left as strings), strip namespace prefixes so ns:foo becomes foo, and keep XML comments as a #comment key. The tool is bidirectional: a Swap button and mode tabs flip it into a JSON to XML converter that reverses every rule, and uploads and URLs auto-detect which direction to use from the first character. Toggle pretty-printing, choose the attribute prefix and text key, and copy the result or download a .json file. A live preview and byte-size stats update as you type, and everything runs on your device so private data never leaves your machine (inputs up to 25 MB).
Attributes become @-prefixed keys (or _ / $); repeated elements collapse into arrays; mixed text sits under #text
Optional type inference turns “42” / “true” / “null” into real values (round-trip safe, so IDs keep their leading zeros)
Strip namespace prefixes (ns:foo → foo), preserve CDATA as #cdata, and keep comments as #comment
Bidirectional: a Swap button flips to JSON → XML, and files / URLs auto-detect the direction
Copy or download .json — parsed with the native DOMParser, 100% client-side, inputs up to 25 MB
What is
XML to JSON Converter
An XML to JSON converter transforms XML — the tag-based markup used by SOAP web services, RSS and Atom feeds, SVG, Android resource files, Maven build descriptors, sitemaps and countless enterprise and legacy systems — into JSON, the lightweight, nested format that web APIs and JavaScript consume natively. The two models do not line up one-to-one: XML has elements, attributes, text nodes, CDATA sections, comments and namespaces, whereas JSON has only objects, arrays, strings, numbers, booleans and null, with no notion of an attribute or a distinction between a single element and a one-item list. A converter therefore needs conventions to bridge the gap. The widely used approach — and the one this tool follows — marks each attribute with a prefix on its key (commonly @, so id=“7” becomes “@id”: “7”), stores the text of an element that also carries attributes or children under a reserved #text key, keeps a CDATA section under a #cdata key, and turns repeated sibling elements that share a tag name into a JSON array while a lone element stays an object. Empty leaf elements become null. This converter is 100% client-side: it parses the XML with the browser’s native DOMParser and builds the JSON in memory with no upload, and it is bidirectional — one click swaps it into a JSON to XML converter that applies every rule in reverse. It lets you control the attribute prefix (@, _ or $) and text key (#text, _text or $t), toggle pretty-printing, optionally infer numbers, booleans and null from text, strip namespace prefixes, preserve CDATA and keep comments. Its honest limits: because JSON has no attribute or namespace concept the mapping relies on reserved prefixes and keys rather than a formal schema, mixed content and namespace edge cases can round-trip imperfectly, type inference is deliberately conservative to avoid corrupting IDs, and very large inputs are bounded by browser memory (a 25 MB cap).
File Tools
Related terms
XMLJSONattributesCDATAnamespacesDOMParserRSSSOAPsitemap.xmlelementtext nodetype inferenceJSON to XMLround-tripcomments
Frequently Asked Questions
No. The XML is parsed and the JSON is built entirely in your browser — there is no upload, server or account, so your data never leaves your device.
Nothing is uploaded. When you paste text or open a file the converter reads it locally with the browser’s File API, parses it into a document tree with the native DOMParser, and serialises the JSON on your device in JavaScript. There is no server, API, database or tracking in the processing path, so a SOAP response, config file, RSS feed or any other sensitive data stays on your machine. The tool works offline once cached, and closing the tab discards everything. The one case where data touches the network is if you paste a remote URL for the tool to fetch — and even then the response is downloaded straight into your browser and never sent anywhere else. The only optional network use anywhere on the site is consent-gated advertising, which never sees your file.
Attributes become keys prefixed with @ (or _ / $), an element’s text sits under a #text key, repeated sibling elements collapse into an array, and empty elements become null.
The converter uses simple, well-known conventions. Every attribute becomes a key on the element’s object marked with the chosen prefix — @ by default, switchable to _ or $ — so <book id=“7”> yields {“book”: {“@id”: “7”}}. When an element carries both attributes (or child elements) and its own text, that text is stored under the reserved #text key so nothing is lost; a plain leaf element with only text becomes a simple string, and an empty leaf becomes null. Crucially, when several sibling elements share a tag name they are grouped into a JSON array, so a list of <item> elements becomes an array while a single <item> stays an object. CDATA can be preserved under a #cdata key and XML comments can be kept under #comment, or both can be dropped.
Yes — an optional “Infer types” pass turns “42”, “true” and “null” into a real number, boolean or null, and it is round-trip safe so IDs with leading zeros stay strings.
By default every value is emitted as a string, because XML is text between tags and has no type system. Turn on the “Infer types” option and the converter coerces obvious scalars: “true” and “false” become booleans, “null” becomes null, and numeric text becomes a number. The inference is deliberately conservative and round-trip safe — a value is only treated as a number when converting it back to a string reproduces the original exactly — so identifiers, phone numbers and codes with leading zeros such as “007” are left as strings rather than silently mangled into 7. You can also strip namespace prefixes so ns:foo becomes foo, which keeps keys clean when you do not need the namespace.
Yes — a Swap button and mode tabs flip the tool into a JSON to XML converter that reverses every rule; the main limits are namespaces, type fidelity and a 25 MB input cap.
The tool is fully bidirectional. A Swap button and the XML → JSON / JSON → XML tabs flip it into a JSON to XML converter that applies the same conventions in reverse — @-prefixed keys become attributes, #text supplies element text, arrays repeat the parent tag — and uploads or fetched URLs auto-detect the direction from the first character. The honest limits follow from the models themselves: XML namespaces have no native JSON equivalent, so they are preserved as prefixed keys or xmlns attributes rather than as a formal namespace; mixed content and CDATA can round-trip imperfectly; and because everything is text, type inference is optional and conservative. Inputs are held in browser memory under a 25 MB cap, and loading a remote URL only works when that server sends permissive CORS headers.
Detailed Explanation
📖How It Works
Converting XML to JSON in Your Browser
The XML to JSON Converter turns XML — the tag-based markup used by SOAP, RSS and Atom feeds, SVG, Android resources, Maven builds and sitemaps — into clean JSON without ever uploading it. Paste XML, drop in an .xml / .json / .txt file, or fetch a CORS-enabled URL, and it converts live as you type using the browser’s native DOMParser. It bridges the two data models with well-known conventions: each attribute becomes a key marked with a prefix (@ by default, switchable to _ or $), an element’s own text sits under a #text key when it also has attributes or children, repeated sibling elements that share a tag name collapse into a JSON array, and empty leaf elements become null. The tool is bidirectional — a Swap button flips it into a JSON to XML converter — and uploads or URLs auto-detect the direction from the first character. Everything runs locally in JavaScript, so SOAP responses, feeds and configuration data never leave the device.
Attributes become @-prefixed keys (or _ / $); an element’s text sits under #text; empty elements become null
Repeated sibling elements collapse into a JSON array; a single element stays an object
Parsed with the native DOMParser from pasted text, an .xml / .json / .txt file, or a CORS-enabled URL
100% client-side — nothing is uploaded to any server
📋Use Cases
Making Legacy XML Usable in Modern Apps
Modern front ends, JavaScript and NoSQL stores speak JSON, but a great deal of data still arrives as XML — SOAP API responses, RSS and Atom feeds, Android strings.xml resources, Maven POMs, sitemaps and exports from older enterprise systems. This converter makes that XML immediately usable: attributes are surfaced as @-prefixed keys you can read like any other field, repeated records become arrays you can map or filter, and optional type inference turns numeric and boolean text into real JSON values so you can compute with them directly. Turn on namespace stripping to drop ns: prefixes when you only care about the data, keep CDATA under #cdata when payloads embed markup, and preserve comments as #comment when they carry meaning. When you need to go the other way — feeding an XML-only system from JSON — the same page flips with one click into the companion JSON to XML direction.
Turns SOAP responses, RSS / Atom feeds, Android strings.xml, Maven POMs and sitemaps into usable JSON
Optional type inference yields real numbers and booleans you can compute with
Namespace stripping, #cdata preservation and #comment retention for real-world XML
One-click Swap flips to the reverse JSON → XML conversion
🔧Technical Details
DOMParser, Prefixes and Array Detection
Conversion runs in a debounced client-side effect on every keystroke: the input is parsed with the browser’s native DOMParser into a document tree, which is then walked recursively to build the JSON. An attribute is emitted as a key on the element’s object marked with the active prefix (@ by default, or _ or $); the reserved #text key holds the text of a mixed-content element; a #cdata key preserves CDATA sections; and a #comment key keeps XML comments when they are not ignored. Array detection is structural — when two or more sibling elements share a tag name they are grouped into an array, while a lone element stays an object — and empty leaf elements become null. The optional “Infer types” pass coerces scalars conservatively: a value becomes a number only when converting it back to a string reproduces the original exactly, so IDs and leading-zero codes are never mangled. Output can be pretty-printed or compact, the text key is selectable (#text, _text or $t), and byte-size stats update for both sides; the whole input is held and processed in memory under a 25 MB cap.
Debounced live conversion: native DOMParser then a recursive walk to JSON
@-prefixed keys for attributes, #text for mixed text, #cdata for CDATA, #comment for comments
Structural array detection groups same-name siblings; empty leaves become null
Round-trip-safe type inference; pretty or compact output; input processed in memory (25 MB cap)
⚠️Limitations
Honest Limitations
The converter is honest about where the XML and JSON models diverge. JSON has no attribute or namespace concept, so the mapping leans on reserved prefixes and keys rather than a formal schema: attributes are carried as @-prefixed keys and namespaces stay as prefixed tag names or xmlns attributes unless you strip them. Mixed content and namespace edge cases can round-trip imperfectly, which is inherent to the two models rather than a bug. Type inference is deliberately conservative and off by default, because aggressively coercing text would corrupt identifiers, phone numbers and leading-zero codes; even when enabled it only converts values that survive a string round-trip. Comments and CDATA are preserved only when you ask for them. Everything is held in browser memory, so size is bounded by a 25 MB input cap and very large documents use more RAM. Loading from a remote URL only works when that server sends permissive CORS headers, and the fetch fails with a clear message otherwise rather than silently.
JSON has no attributes or namespaces — they map to @-prefixed keys and prefixed tags, not a schema
Mixed content and namespace edge cases can round-trip imperfectly
Type inference is conservative and off by default so IDs and leading zeros are never mangled
Bounded by browser memory (25 MB cap); remote-URL loading needs permissive CORS or it fails clearly
🔒Privacy & Security
Privacy: Your Data Stays on Your Device
XML documents often hold exactly the data you should not upload — SOAP responses with customer records, tokens in config files, feeds and enterprise exports — and this converter is built so they never leave your machine. Input is read with the browser’s File API, parsed into a document tree with the native DOMParser and serialised to JSON locally in JavaScript, with no server, upload, database, logging, API or CDN anywhere in the processing path. The tool works offline once cached, and closing the tab discards everything. The only moment anything touches the network is if you explicitly paste a remote URL for the tool to fetch, and even then the response is downloaded straight into your browser and sent nowhere else. The only optional network use anywhere on the site is consent-gated advertising, which never sees your file or its contents.
Read, parsed and serialised entirely in the browser
No server, upload, database, API or CDN in the processing path
Works offline once cached; closing the tab discards everything
Only optional network use is consent-gated ads, which never see your file
XML to JSON Converter — conventions, options and limits
Capability
Support
Notes
Attributes
Keys prefixed with @ (or _ / $)
id=“7” becomes “@id”: “7” on the element’s object
Text & CDATA
#text for mixed text, #cdata for CDATA
A plain leaf becomes a string; an empty leaf becomes null
Repeated elements
Same-name siblings collapse into an array
A single element stays an object; detection is structural
Type inference
Optional numbers / booleans / null
Round-trip safe, so IDs and leading-zero codes stay strings
Namespaces & comments
Strip ns: prefixes, keep comments as #comment
Namespaces have no JSON equivalent; kept as prefixed keys / xmlns unless stripped
The converter parses XML with the native DOMParser, marks attributes with an @ (or _ / $) prefix, stores mixed text under #text and CDATA under #cdata, collapses same-name sibling elements into arrays, and turns empty leaves into null. Optional passes infer numbers, booleans and null (round-trip safe), strip namespace prefixes and keep comments. A Swap button flips to the reverse JSON to XML direction. It is bounded by a 25 MB browser-memory cap and remote-URL loading needs permissive CORS. Everything runs in the browser; nothing is uploaded.