XML to JSON Converter

Transform XML data into JSON format

XML Input

JSON Output

About XML to JSON Converter

Convert XML data to JSON format with flexible output options. Perfect for web development, APIs, NoSQL databases, and JavaScript applications that work with JSON data.

Key Features

  • Multiple Formats: Array of Objects (headers as keys) or Array of Arrays (headers in first row)
  • Type Detection: Automatically converts numbers, booleans, and null values
  • Pretty Print: Optional indentation for readable JSON
  • Compact Output: Minified JSON for production use
  • RFC 8259 Compliant: Generates valid JSON according to specifications
  • Attribute Support: Includes XML attributes as fields (prefixed with @)

How to Use

  1. Input XML Data: Paste your XML data or upload an .xml file
  2. Choose Format: Select Array of Objects or Array of Arrays
  3. Toggle Pretty Print: Enable for readable output, disable for compact
  4. Copy or Download: Copy to clipboard or download as .json file

Output Formats

  • Array of Objects: Each row is an object with headers as keys - ideal for JavaScript, REST APIs, and document databases
  • Array of Arrays: First array contains headers, subsequent arrays contain data - compact format for data processing

Example Conversion

XML Input:

<?xml version="1.0"?>
<employees>
  <employee>
    <id>1</id>
    <name>John Doe</name>
    <age>28</age>
    <active>true</active>
  </employee>
  <employee>
    <id>2</id>
    <name>Jane Smith</name>
    <age>34</age>
    <active>false</active>
  </employee>
</employees>

Array of Objects Output:

[
  {
    "id": 1,
    "name": "John Doe",
    "age": 28,
    "active": true
  },
  {
    "id": 2,
    "name": "Jane Smith",
    "age": 34,
    "active": false
  }
]

Array of Arrays Output:

[
  ["id", "name", "age", "active"],
  [1, "John Doe", 28, true],
  [2, "Jane Smith", 34, false]
]

Type Conversion

  • Numbers: Numeric strings are converted to JSON numbers (e.g., "42" → 42)
  • Booleans: "true" and "false" strings are converted to JSON booleans
  • Null: Empty strings and "null" are converted to JSON null
  • Strings: All other values remain as JSON strings

Supported XML Structures

  • Repeating Elements: Automatically detects common record names (row, record, item, entry, employee, product, user)
  • Nested Elements: Extracts child element values as fields
  • Attributes: Includes XML attributes as fields (prefixed with @)
  • Mixed Content: Handles various XML structures intelligently

Common Use Cases

  • Web Development: Convert XML data for JavaScript applications
  • REST APIs: Transform XML responses to JSON format
  • NoSQL Databases: Import XML data into MongoDB, CouchDB, etc.
  • Data Processing: Process XML data with JSON-based tools
  • Configuration Files: Convert XML configs to JSON
  • Data Migration: Migrate from XML-based systems to JSON-based systems

JSON Standards

The generated JSON follows RFC 8259 specifications:

  • Proper escaping of special characters
  • UTF-8 encoding support
  • Valid JSON syntax for all data types
  • Compatible with all JSON parsers

Privacy & Security

All conversions happen locally in your browser. Your XML data is never uploaded to any server, ensuring complete privacy and security.