XML to JSON Converter
Convert XML to JSON online. Transform XML elements, attributes, and CDATA into structured JSON objects with fast in-browser execution.
How XML → JSON Works
- Uses fast-xml-parser to construct JavaScript objects from XML.
- Converts XML attributes into @_ prefixed properties.
- Transforms repeating XML tags into JSON arrays.
Example Input & Output
Parses XML elements and attributes into a structured JSON hierarchy, converting numeric and boolean strings into native JSON types.
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book category="fiction">
<title>The Great Gatsby</title>
<author>F. Scott Fitzgerald</author>
<year>1925</year>
<price>10.99</price>
</book>
</bookstore>{
"bookstore": {
"book": {
"@_category": "fiction",
"title": "The Great Gatsby",
"author": "F. Scott Fitzgerald",
"year": 1925,
"price": 10.99
}
}
}Common Use Cases
Modernizing Legacy APIs
Convert legacy XML SOAP service responses into JSON for frontend consumption.
Data Migration
Ingest XML exports into MongoDB or PostgreSQL JSONB databases.
Key Specifications & Gotchas
Single Item Arrays
A single XML element with repeating sibling potential may parse as an object rather than an array unless configured.
Frequently Asked Questions
How are XML attributes converted to JSON?
Attributes are mapped to prefixed properties (e.g. @_category) within the corresponding object.
How are repeating XML elements handled?
Repeating tags with identical names are grouped into JSON arrays.
Related XML & Data Format Tools
View all 41 tools →JSON → XML
Convert JSON to XML online. Transform JSON objects and arrays into clean, well-formed XML documents with customizable root tags.
XML Formatter
Format and beautify XML code online. Indent XML tags, align attributes, fix malformed tags, and pretty print XML documents in your browser.
XML Validator
Validate XML syntax and well-formedness online. Detect unclosed tags, attribute syntax mistakes, and XML parsing errors with exact line numbers.