Ctrl + K
Converters

JSON to XML / XML to JSON

Convert data formats instantly between structured JSON objects and nested XML markup strings.

JSON Input 8 lines
XML Output 8 lines

All conversions happen locally in your browser. Your data is never sent to any server. The tool uses the native DOMParser API for XML parsing.

JSON and XML are the two most widely used data interchange formats on the web. APIs, configuration files, and enterprise systems often require converting between them. Our JSON to XML converter transforms structured JSON objects into well-formed XML markup, and the reverse XML to JSON converter parses XML back into clean, indented JSON — all in your browser.

Conversion Rules

Objects → Nested Elements

JSON objects become nested XML elements. Each key becomes a child element tag.

Arrays → Repeated Elements

JSON arrays are converted to repeated XML elements. The element name is the singular form of the parent key.

Primitives → Text Content

Strings, numbers, booleans, and null values become the text content of their parent XML element.

Attributes → @ Prefix

XML attributes are represented as properties with an @ prefix in JSON. Text content uses a #text key.

Example Conversion

JSON Input

{
  "book": {
    "title": "The Great Gatsby",
    "author": "F. Scott Fitzgerald",
    "year": 1925,
    "genres": ["Fiction", "Classic"],
    "inStock": true
  }
}

XML Output

<root>
  <book>
    <title>The Great Gatsby</title>
    <author>F. Scott Fitzgerald</author>
    <year>1925</year>
    <genres>Fiction</genres>
    <genres>Classic</genres>
    <inStock>true</inStock>
  </book>
</root>

How to Use the Converter

  1. Select a direction — Choose JSON to XML or XML to JSON using the mode buttons.
  2. Paste your input — Enter your source data in the left panel.
  3. View the result — The converted output appears instantly in the right panel with proper indentation.
  4. Copy or download — Use the Copy button or download the output as a file.

Key Features

  • Bidirectional Conversion

    Convert both directions — JSON to XML and XML to JSON — with a single click.

  • Array Handling

    JSON arrays become repeated XML elements with intelligent singular naming.

  • Attribute Support

    XML attributes are preserved with @ prefix notation in the JSON output.

  • Proper Indentation

    Both JSON and XML outputs are beautifully indented for readability.

  • XML Character Escaping

    Special XML characters (&, <, >, ", ') are properly escaped.

  • 100% Private

    All processing happens locally. No data is uploaded anywhere.

Frequently Asked Questions

How are JSON arrays converted to XML?
JSON arrays become repeated XML elements. The element name is derived from the parent key by removing the trailing "s". For example, "books": [...] becomes multiple <book> elements.
How are XML attributes handled in JSON?
XML attributes are prefixed with @ in the JSON output. Text content within elements with attributes uses a #text key. For example, <item id="5">Hello</item> becomes {"@id": "5", "#text": "Hello"}.
Can I convert very large files?
Since all processing is client-side, very large files (50 MB+) may cause browser slowdowns. For typical API payloads and configuration files (under 5 MB), the tool works smoothly.