JSON ↔ XML Converter
Convert between JSON and XML formats with attribute support.
100% Private — Your files never leave your device.
All processing happens in your browser. Nothing is uploaded to any server.
@_attributeName in JSON. For example, <user id="1"> becomes {"@_id": "1"}.How it works
When to Convert JSON to XML
Common scenarios for JSON → XML conversion:
- SOAP services: Legacy enterprise systems often require XML
- XML APIs: Some platforms (RSS, Atom, SAML) are XML-native
- Document generation: XML-based formats like SVG, XHTML, and Office documents
- Regulatory compliance: Some industries require XML for data exchange (HL7, XBRL)
When to Convert XML to JSON
Common scenarios for XML → JSON conversion:
- Modern web apps: JavaScript works natively with JSON, not XML
- API modernization: Migrating legacy XML APIs to JSON REST endpoints
- Data processing: JSON is easier to query and transform with JavaScript/Python
- RSS/Atom feeds: Parse XML feeds into JSON for web dashboards
Format Comparison
<!-- XML --> // JSON
<user id="1"> {"user": {
<name>Alice</name> "@_id": 1,
<roles> "name": "Alice",
<role>admin</role> "roles": {
<role>editor</role> "role": ["admin", "editor"]
</roles> }
</user> }}
| Feature | JSON | XML |
|---|---|---|
| Data types | String, number, boolean, null, array, object | Text only (types via schemas) |
| Attributes | Not native | First-class (id="1") |
| Comments | Not supported | <!-- comment --> |
| Namespaces | Not supported | Full namespace support |
| Schema validation | JSON Schema | XSD, DTD, RelaxNG |
| File size | Smaller | Larger (verbose tags) |
| Parsing speed | Faster | Slower |
| Human readability | Good | Good (but verbose) |
Attribute Convention
This tool uses the @_ prefix convention to represent XML attributes in JSON:
| XML | JSON |
|---|---|
<div class="main"> | {"div": {"@_class": "main"}} |
<img src="photo.jpg" alt="Photo"/> | {"img": {"@_src": "photo.jpg", "@_alt": "Photo"}} |
<input type="text" value="hello"/> | {"input": {"@_type": "text", "@_value": "hello"}} |
How It Works
This tool uses fast-xml-parser, one of the fastest and most reliable XML parsers for JavaScript with 18M+ weekly npm downloads. All conversion happens in your browser — no data is sent to any server.
Real-World Examples
Converting a REST API response to XML for a SOAP service
A developer integrates a modern REST API (JSON) with a legacy SOAP service that only accepts XML. The JSON response with nested user objects and arrays is converted to well-formed XML. Array items become repeated elements, nested objects become child elements, and the output includes proper XML declaration and indentation.
Parsing an XML configuration for a JavaScript application
An application uses an XML configuration file with attributes like '<database host="localhost" port="5432"/>'. Converting to JSON produces '{"database": {"@_host": "localhost", "@_port": 5432}}'. The @_ prefix convention clearly distinguishes attributes from child elements, and numeric values are automatically parsed.
Converting an RSS feed to JSON for a dashboard
A developer builds a news dashboard and needs to parse RSS feeds (which are XML). Converting the RSS XML to JSON produces structured data with channel info, item arrays, and publication dates that can be directly consumed by React components. The 200-item feed converts in under a second.
Frequently Asked Questions
How are XML attributes represented in JSON?
How are XML arrays handled?
What about CDATA sections?
Is the conversion lossless?
What about XML namespaces?
Can I convert large XML files?
Related Calculators
JSON Formatter
Format, validate, and beautify JSON with syntax highlighting.
JSON ↔ YAML Converter
Convert between JSON and YAML formats instantly.
CSV ↔ JSON Converter
Convert between CSV and JSON formats. Paste or upload, download instantly.
Markdown ↔ HTML Converter
Convert Markdown to HTML and back. Live preview included.
Base64 Encode/Decode
Encode text or files to Base64 and decode Base64 back instantly.