XML ↔ JSON Converter
Convert XML to JSON or JSON to XML instantly. Handles attributes, text content, and repeated elements. 100% client-side.
How to Use the XML to JSON Converter
- Choose a direction — "XML to JSON" or "JSON to XML" using the chips above the input.
- Paste your data into the input area on the left.
- View the converted output on the right, updating as you type.
- Copy or download the result as a
.jsonor.xmlfile.
Conversion Conventions
Converting between XML and JSON requires a mapping convention because the two formats have fundamentally different concepts. This tool uses the widely adopted BadgerFish-inspired convention:
- XML attributes become JSON properties prefixed with
@(e.g.,<el id="1">becomes{ "@id": "1" }) - Mixed content (element with both attributes and text) uses
#textfor the text portion - Repeated sibling elements are grouped into a JSON array
- Text-only elements with no attributes become plain string values
- Nested elements become nested JSON objects
XML vs. JSON: Key Differences
XML and JSON serve similar purposes but have different strengths. XML supports attributes (metadata about elements), mixed content (text and child elements in the same element), namespaces (XML Schema, SOAP), comments, processing instructions, and CDATA sections. JSON is simpler, lighter, and maps directly to programming language data structures. Most modern REST APIs use JSON, while SOAP APIs, RSS/Atom feeds, SVG graphics, Microsoft Office files (DOCX, XLSX), and many enterprise system integrations use XML. Converting between them is common when migrating legacy systems or working with multi-format APIs.
Common Use Cases
- SOAP to REST migration — Convert SOAP XML responses to JSON for use with modern REST clients
- RSS/Atom feed parsing — Convert feed XML to JSON for JavaScript processing
- Configuration files — Convert Maven/Gradle XML configs to JSON format for tooling
- API format bridging — Some APIs accept both formats; convert before submission
- Data transformation pipelines — Convert XML exports from legacy systems to JSON for modern databases
Limitations
The conversion cannot perfectly preserve all XML features. XML namespaces, processing instructions (<?xml ... ?>), CDATA sections, and XML comments are not preserved in the JSON output. The root element name is preserved as the top-level key in the JSON object. When converting JSON back to XML, properties with @ prefix become attributes, and arrays generate repeated elements with the same tag name. The root element is named "root" by default if the JSON starts with an object.
Working with SOAP XML
SOAP XML responses typically include namespace prefixes (e.g., <ns1:Body>) and deeply nested envelope structures. The converter handles namespaced elements by preserving the prefix as part of the property name in JSON. For complex SOAP responses, you may need to navigate through the envelope structure in the resulting JSON. For production SOAP integration, consider using dedicated SOAP client libraries that handle namespace resolution automatically.