XML to JSON
Transform XML documents into clean JSON objects with configurable attribute prefixes, repeated element arrays, and 100% client-side privacy.
- Runs in your browser
- Free, no signup
{
"bookstore": {
"@xmlns:meta": "https://example.com/ns/meta",
"book": [
{
"@id": "bk101",
"@category": "computer",
"title": {
"@lang": "en",
"#text": "Clean Architecture"
},
"author": "Robert C. Martin",
"year": 2017,
"price": {
"@currency": "USD",
"#text": 29.99
},
"meta:tags": {
"meta:tag": [
"software",
"architecture"
]
},
"description": "A craftsman's guide to software structure and design."
},
{
"@id": "bk102",
"@category": "fiction",
"title": {
"@lang": "en",
"#text": "The Hobbit"
},
"author": "J.R.R. Tolkien",
"year": 1937,
"price": {
"@currency": "USD",
"#text": 14.99
},
"available": null
}
]
}
}
XML to JSON Mapping & Conversion Rules
XML and JSON model hierarchical data differently. ToolDuck uses standardized, deterministic conversion rules so your downstream APIs receive predictable structures:
Attributes
XML attributes are prefixed with @ (e.g. @id or @category). You can customize or disable this prefix in the options toolbar.
Repeated Elements
When multiple sibling elements share the same tag name (like repeated <book> tags), they are automatically grouped into a JSON array.
Mixed Content & Text
If an element contains both attributes and inner text, the text is mapped to #text. Text-only elements convert directly to simple values.
Empty Elements
Self-closing tags without attributes (e.g. <available />) convert to null, maintaining exact schema representation.
CDATA & Escaping
Content inside <![CDATA[ ... ]]> blocks is extracted as unescaped plain string text without losing HTML or special characters.
XXE & Client-Side Safety
All parsing runs 100% in your browser. External entities are completely blocked and zero bytes leave your device.
Your files are processed locally in your browser and are not uploaded to our server.
Migrating legacy SOAP endpoints, RSS feeds, or XML configuration files into modern REST and JSON APIs can be challenging because XML and JSON structure data differently. ToolDuck provides a deterministic, highly configurable XML to JSON converter that runs entirely inside your browser.
The converter accurately handles nested elements, attributes (configurable with @ or custom prefixes), repeated sibling elements (automatically grouped into JSON arrays), CDATA sections, and XML namespaces. Any syntax error is detected immediately and displayed with exact line and column numbers.
How to use this tool
- Paste your XML document into the left editor or click "Load Sample" to try a demonstration XML document.
- Adjust conversion settings in the toolbar: customize attribute prefixes (@, _, or none), toggle number/boolean parsing, or strip XML namespaces.
- The formatted JSON output updates live in the right editor as you type or adjust options.
- Click "Copy JSON" or "Download .json" to export the converted JSON payload.
Standardized XML to JSON Conversion Rules
Attributes: Stored with a customizable prefix (default: @attr) to prevent collisions with child elements sharing the same name.
Repeated Elements: When sibling elements share the same tag name (such as multiple <item> tags), they are automatically grouped into a single JSON array.
Mixed Content: If an element contains both attributes and inner text, the text is captured under the configurable #text key.
Empty Nodes: Self-closing empty elements without attributes (like <tag />) map cleanly to null.
XXE Prevention and Client-Side Security
XML external entity (XXE) attacks are a major concern when processing untrusted XML. ToolDuck executes 100% inside your web browser without server-side processing.
External entities (SYSTEM and PUBLIC DTDs) are blocked by design, and no network requests are ever made during parsing. Your data remains strictly private on your device.
Frequently asked questions
How are repeated XML elements handled in JSON?
Whenever two or more sibling elements share the same tag name, the converter automatically transforms them into a JSON array containing each element's parsed value.
Can I remove the "@" prefix from XML attributes?
Yes. In the toolbar, change the "Attribute Prefix" dropdown from "@ Prefix" to "No Prefix" or "_ Underscore" according to your preference.
Does this tool preserve CDATA text?
Yes. Text inside <![CDATA[ ... ]]> blocks is extracted as unescaped string data, ensuring HTML markup, angle brackets, and special characters are preserved accurately.
Is any of my XML uploaded to an external server?
No. All parsing and conversion happen locally inside your browser using client-side JavaScript. No data is transmitted across the internet.