More games at WuGames.ioSponsoredDiscover free browser games — play instantly, no download, no sign-up.Play

XML-JSON Converter

Convert XML to JSON and JSON to XML online, in your browser, no upload. Keeps attributes, CDATA, leading zeros and nested structures intact.

Upload
Drag & drop file here
or click to browse

About XML-JSON Converter

XML-JSON Converter is a free online tool that converts between XML (eXtensible Markup Language) and JSON (JavaScript Object Notation) formats. Convert XML to JSON or JSON to XML with support for attributes, nested structures, and custom formatting—all processed locally in your browser for complete privacy.

Why convert between XML and JSON?

XML and JSON are both popular data interchange formats, but they're used in different contexts:

- XML: Common in legacy systems, SOAP APIs, configuration files, and enterprise applications
- JSON: Standard for modern REST APIs, web applications, and NoSQL databases

Converting between formats allows you to:
- Integrate legacy XML systems with modern JSON APIs
- Process XML data in JavaScript applications
- Transform JSON data for XML-based systems
- Migrate data between different platforms

How are XML attributes handled?

XML attributes are converted to JSON properties with a special prefix:

- Enabled (default): Attributes become properties with '@_' prefix
Example: <book id="1"> becomes {"@_id": "1"}

- Disabled: Attributes are ignored during conversion

When converting JSON to XML, properties with '@_' prefix are automatically converted back to XML attributes, preserving the original structure.

Does my data leave my device?

No. All XML-JSON conversion happens entirely in your browser using JavaScript. Your data never leaves your machine, ensuring complete privacy for sensitive information like configuration files, API responses, or confidential data structures.

What is 'Parse Tag Values'?

This option automatically converts XML text content to appropriate data types in JSON:

- Enabled (default): Converts numbers, booleans, and null values
Example: <age>30</age> becomes {"age": 30} (number, not string)

- Disabled: All values remain as strings
Example: <age>30</age> becomes {"age": "30"} (string)

This is useful when you want to preserve exact data types for use in programming.

XML-JSON Converter — Convert XML to JSON and JSON to XML online, in your browser, no upload. Keeps attributes, CDATA, leading zeros and neste
XML-JSON Converter

Can I customize the XML output formatting?

Yes. When converting JSON to XML, you can:

1. Set a custom root element name (default: 'root')
2. Enable/disable XML formatting (pretty-print)
3. Choose indent size (2 or 4 spaces)

The converter automatically adds the XML declaration (<?xml version="1.0"?>) and properly formats nested structures for readability.

How are JSON arrays handled in XML?

JSON arrays are converted to repeated XML elements with the same tag name:

JSON: {"books": [{"title": "Book 1"}, {"title": "Book 2"}]}
XML:
<books>
<title>Book 1</title>
<title>Book 2</title>
</books>

This is the standard XML representation of lists, commonly used in RSS feeds, SOAP responses, and configuration files.

How are CDATA sections and XML comments handled?

Keep the 'Keep CDATA & Comments' option enabled (the default) for a lossless round-trip. CDATA sections are stored under a '#cdata' key and XML comments under '#comment', then rebuilt as <![CDATA[...]]> and <!-- ... --> when you convert back to XML. This matters when your XML wraps HTML, scripts or escaped markup inside CDATA — without it those payloads and any comments are silently dropped. Disable the option only if you want a flatter JSON and do not need to preserve them.

Note: this tool uses the fast-xml-parser library, a widely used standard for XML/JSON conversion in Node.js and browser tooling.

Why did my ZIP code 01234 turn into 1234 — how do I keep leading zeros?

When 'Parse Tag Values' is on, fast-xml-parser tries to coerce numeric-looking text into real numbers, which strips leading zeros and can corrupt ZIP codes, account numbers, SKUs and phone numbers. Keep the 'Preserve Leading Zeros' option enabled (the default): it sets leadingZeros:false so any value starting with a zero — like <zip>01234</zip> — stays the string "01234". This is essential for ERP exports, SOAP API responses and config files where the exact text matters. If you want every value kept as a string, turn off 'Parse Tag Values' entirely.

How do I force an element to always be an array, and how are namespaces handled?

By default a tag that appears once becomes a JSON object and the same tag appearing multiple times becomes an array, so single-item lists can lose their array shape. If your downstream code always expects an array, post-process the JSON or wrap the value in [] after conversion. Namespaced elements and attributes (for example xmlns:soap or soap:Body) are preserved with their prefix as part of the key, so SOAP envelopes round-trip correctly. Combine this with 'Keep CDATA & Comments' and 'Preserve Leading Zeros' for safe data-migration work.