XMLToJSON Free Online XML to JSON Converter
100% Free, Private & Instant XML to JSON Converter — Parse & Format Structured Data Online.
Parser Settings
Waiting for XML input
Paste XML, drop an .xml file, or load the sample to begin.
XML Input
JSON Output LIVE
Your JSON will appear here instantly.
Converted locally — nothing leaves your device.
Tip: press Ctrl + Shift + C to copy the JSON output.
How to Convert XML to JSON Online
XMLToJSON 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.
-
01
Add your XML
Paste raw XML into the input pane, drag & drop an .xml file, or click “Load Sample XML”.
-
02
Choose settings
Pick how attributes are handled, whether repeated tags become arrays, and pretty print or minified output.
-
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, XMLToJSON 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 XMLToJSON?
- ✓Instant live preview — JSON updates as you type, side by side with your XML.
- ✓Real-time validation — malformed or unclosed tags are reported with line and column.
- ✓Private by design — 100% client-side; your data never leaves the browser.
- ✓Developer-friendly output — pretty print with 2 or 4 spaces, or minify to a single line.
- ✓Works with real-world XML — RSS, Atom, SOAP, sitemaps, SVG, KML, config files and API responses.
- ✓Free forever — no sign-up, no limits, works on desktop and mobile.
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. XMLToJSON 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?
▾
XMLToJSON 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 XMLToJSON 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.
Related Developer Tools
More free, private, browser-based utilities for working with data.
JSON to CSV Converter
Flatten JSON arrays into spreadsheet-ready CSV.
CSV to JSON Converter
Turn CSV files into clean JSON with live preview.
JSON Formatter
Beautify, validate and minify JSON.
Base64 Encoder
Encode and decode Base64 text and files.
Regex Tester
Test and debug regular expressions live.
Unix Timestamp Converter
Convert epoch time to human dates.