JSON ↔ XML Converter

Convert between JSON and XML formats instantly with customizable options.

About This Tool

The JSON to XML Converter is a free browser-based tool that transforms data between JSON and XML formats in real time. Whether you are migrating data from a modern REST API to a legacy SOAP service, generating configuration files for XML-based systems, or simply need to inspect data in a different format, this tool handles the conversion instantly.

All processing happens entirely in your browser using native JavaScript APIs. Your data never leaves your machine — there are no server round-trips, no logging, and no third-party analytics on your input. This makes it safe for sensitive payloads such as internal API responses, configuration files, and data exports containing proprietary information.

When converting JSON to XML, you can customize the root element name, the element name used for array items, and the indentation level. An optional "attributes for primitives" mode maps simple values (strings, numbers, booleans) to XML attributes rather than child elements, producing more compact output that matches common XML conventions.

When converting XML to JSON, the tool uses the browser's built-in DOMParser for reliable parsing. It detects repeated elements with the same tag name and automatically converts them to JSON arrays. XML attributes are preserved with a configurable prefix (default @_), and mixed content is handled gracefully. The converter also auto-detects primitive types: numeric strings become numbers, "true" and "false" become booleans, and "null" becomes a JSON null value.

The bidirectional swap feature lets you convert output back into input with a single click, making it easy to round-trip data or experiment with different options. All five special XML characters (&, <, >, ", ') are properly escaped during JSON-to-XML conversion to ensure valid output every time.

How to Use

  1. Select the conversion direction using the JSON → XML or XML → JSON tabs.
  2. Paste or type your data into the Input panel on the left. The output updates automatically in real time.
  3. Adjust options in the settings panel: root element name, array item element name, indentation, attribute mode (JSON→XML), or attribute prefix (XML→JSON).
  4. Click Swap to reverse the direction and use the current output as the new input.
  5. Click Sample to load example data for the current direction.
  6. Click Copy (or press Ctrl+Shift+C) to copy the output to your clipboard.
  7. Click Clear to reset the input and start fresh.

Popular JSON ↔ XML Examples

View all JSON ↔ XML examples →

FAQ

Is my data safe when using this converter?

Yes. All conversion is performed client-side in your browser using native JavaScript APIs (DOMParser for XML, JSON.parse and JSON.stringify for JSON). No data is sent to any server, making it safe for sensitive or proprietary data.

How are JSON arrays converted to XML?

Arrays are wrapped in a parent element using the JSON key name, and each array item is wrapped in an element whose name you can customize (default: <item>). For example, a JSON array at key "users" becomes <users><item>...</item></users>.

How are XML attributes handled when converting to JSON?

XML attributes are converted to JSON object keys with a configurable prefix. By default the prefix is @_, so an attribute like id="42" becomes "@_id": "42" in JSON. You can change or remove the prefix in the options panel.

What does "Attributes for primitives" do?

When enabled during JSON-to-XML conversion, simple values (strings, numbers, booleans) inside objects are rendered as XML attributes on the parent element rather than as child elements. This produces more compact XML and matches conventions used by many XML schemas.

Does the converter handle repeated XML elements?

Yes. When multiple sibling elements share the same tag name, they are automatically grouped into a JSON array. Single elements remain as plain objects. This heuristic matches the most common convention for representing arrays in XML.

Are special characters properly escaped?

Yes. All five XML special characters (&, <, >, ", ') are properly escaped when converting JSON to XML. When converting XML to JSON, the browser's native DOMParser handles unescaping automatically.

Can I use this tool with large files?

The tool works well with data up to several megabytes. Since all processing is done in the browser, performance depends on your device. For extremely large files, consider using a command-line tool or streaming parser instead.

Related Tools