How to Convert XML to JSON
XML powers a huge amount of the world's data — RSS feeds, SOAP responses, sitemaps, office documents and countless enterprise formats — but it's verbose and awkward to work with in modern code. JSON is lighter and maps directly onto the objects and arrays your programming language already uses. This converter parses your XML with a real parser, then walks the document tree: nested elements become nested objects, repeated tags collapse into arrays, and attributes are preserved with a clear prefix. Turn on type detection and numbers and booleans become real JSON values. Choose pretty or minified output, then copy or download. Everything runs in your browser, so nothing is uploaded.
Paste your XML
Paste your document or load the sample; it's parsed locally with nothing uploaded.
Choose the options
Toggle attribute handling, type detection and pretty vs minified output.
Copy or download
Grab the JSON with one tap or save it as a .json file.
XML vs JSON — What's the Difference?
XML — Extensible Markup Language
A tag-based markup format where data lives inside named elements that can carry attributes and nest to any depth. It's self-describing, supports schemas and namespaces, and has decades of tooling behind it — which is why it still underpins so many enterprise systems, documents and feeds. The trade-off is verbosity: every value is wrapped in opening and closing tags.
JSON — JavaScript Object Notation
A lightweight format built from objects, arrays and typed scalars. It's compact, fast to parse, and maps one-to-one onto native data structures, which makes it the default for web APIs and configuration. Converting XML to JSON strips away the markup overhead and hands you data your code can use directly.
Common Use Cases
Modernise legacy APIs
Turn XML responses from older SOAP or enterprise services into JSON your front-end can consume.
Parse RSS & feeds
Convert RSS or Atom feeds into JSON to render them in a modern app.
Read config files
Bring XML configuration into a JSON-based toolchain without hand-editing.
Inspect documents
Flatten a verbose XML document into readable JSON to understand its structure.
Data migration
Move XML exports into systems and databases that prefer JSON input.
Feed pipelines
Normalise mixed XML sources into consistent JSON for processing.
Testing & mocks
Turn sample XML payloads into JSON fixtures for tests and prototypes.
Quick exploration
A fast, no-install way to see what an XML payload actually contains.
Tips & Best Practices
Keep one clear root element
Well-formed XML has a single root. If your snippet has several top-level elements, wrap them in one parent first.
Decide on attributes early
If you don't need attributes in the JSON, turn them off for a cleaner result focused on element content.
Watch repeated-tag arrays
A tag that appears once is an object; the same tag appearing twice becomes an array — design consumers to handle both.
Use type detection thoughtfully
It's great for numeric data, but turn it off if you need identifiers like 007 or 0123 to stay exact strings.
Minify for machines
Use minified output when the JSON feeds another program, and pretty printing when a person will read it.
Troubleshooting
It says the XML is invalid
XML must be well-formed: tags balanced and properly closed, one root element, and special characters escaped. Fix any unclosed tags and try again.
An expected array is an object
A tag that appears only once is treated as a single object, not an array. If you need a consistent array, ensure the tag repeats or handle both shapes in your code.
Attributes are missing
Turn on 'Include attributes'. They appear in the JSON with an @ prefix so they never clash with child element names.
Numbers stayed as strings
Enable type detection. Values with leading zeros or extra characters are intentionally kept as strings to avoid data loss.
Frequently Asked Questions
How do I convert XML to JSON for free?
Paste your XML above and structured JSON appears instantly. Copy it or download a .json file — free, no signup.
Does it handle nested elements?
Yes. The converter walks the whole document tree, so nested elements become nested JSON objects to any depth.
How are repeated tags handled?
When the same tag appears more than once under a parent, those elements are collected into a JSON array automatically.
What happens to attributes?
With 'Include attributes' on, each attribute appears in the JSON prefixed with @ so it can't clash with child element names. You can also turn attributes off.
Are numbers and booleans detected?
Yes. With type detection on, numeric and true/false values in text and attributes become real JSON numbers and booleans.
What if my XML is invalid?
The tool validates your input and shows a clear message if the XML isn't well-formed, so you can fix balanced or unclosed tags.
Can I keep values as strings?
Yes. Turn off type detection to preserve every value as a string — useful for IDs with leading zeros.
Can I minify the JSON?
Yes. Turn off pretty printing for compact, minified JSON ideal for sending over a network.
Does it support attributes and text together?
Yes. An element with both attributes and text keeps its text under a dedicated #text key alongside the attributes.
Is my data sent to a server?
No. Everything happens inside your browser, so your data never leaves your device — safe even for sensitive files.
Can I download the result?
Yes. Save the output as a .json file, or copy it straight to your clipboard.
Does it handle namespaces?
Namespaced tags are kept with their prefixes as part of the key names, so the structure is preserved.
How large a document can it handle?
It comfortably converts sizeable XML documents, all within your browser.
Does it work with CDATA sections?
Yes. Text inside CDATA is treated as the element's text content.
Does it work on phones?
Yes, in any modern browser on Windows, Mac, Android or iPhone with nothing to install.
Is this converter really free?
Completely free, forever — no account, no ads and no premium wall.
100% free · No signup · Processed in your browser · Data never sent
Last updated: August 2026 · FlipMyFormat XML to JSON Converter
Written and maintained by the FlipMyFormat team · Runs entirely in your browser