Skip to content
XML to JSON

XML to JSON

Convert XML to JSON online. Paste any well-formed XML and get a clean JSON object — with optional attribute preservation and array-detection.

Converts XML to JSON Preserves attributes (as @attributes) Auto-detects repeating elements as arrays Configurable indentation (2 / 4 / minify) Copy and download JSON output Import XML from URL or file Theme switcher Fullscreen editor mode

Input XML

Paste your XML here

JSON Output

Copy or download the converted JSON

Key Features

  • Converts XML to JSON
  • Preserves attributes (as @attributes)
  • Auto-detects repeating elements as arrays
  • Configurable indentation (2 / 4 / minify)
  • Copy and download JSON output
  • Import XML from URL or file
  • Theme switcher
  • Fullscreen editor mode

How to Use

  1. Paste your XML into the input editor.
  2. Toggle whether to keep attributes.
  3. Click Convert to produce JSON.
  4. Copy or download the JSON output.
  5. Need the reverse? Use the JSON to XML converter.

Free Online XML to JSON Converter

Parse any well-formed XML document and convert it into structured JSON with our online XML to JSON converter. Ideal for modernising legacy XML feeds, migrating SOAP responses into JavaScript front-ends, or simply working with XML data inside tools that speak JSON.

How the conversion works

  • Each element becomes a JSON property keyed by the tag name
  • Repeating siblings with the same tag name are grouped into a JSON array automatically
  • Attributes are placed under a special @attributes key (toggle on/off)
  • Mixed content (text + child elements) keeps the text under a #text key
  • Whitespace-only text is trimmed away to keep the output clean

Why this approach?

XML allows mixed content, multiple attributes per element, and namespaces — features that JSON cannot express directly. By using @attributes and #text conventions, the converter preserves every piece of information losslessly while still producing easy-to-consume JSON. Disable attribute preservation when you don't need attributes and want a simpler shape.

Indent options

  • Indent 2: Pretty-printed JSON for readability
  • Indent 4: Extra airy formatting for deeply nested documents
  • Minify: Compact single-line JSON for transmission

Common use cases

  • Translate XML API responses into JSON for modern JavaScript apps
  • Convert sitemap, RSS, or Atom feeds into JSON to display in a SPA
  • Inspect deeply nested SOAP envelopes as JSON
  • Build JSON-based test fixtures from existing XML samples

Pair with related tools

Before converting, clean up your XML with the XML Formatter and ensure it parses cleanly via the XML Validator. After converting, format the JSON output with the JSON Formatter or reverse the operation with the JSON to XML converter.

Privacy

Parsing happens locally using the browser's built-in DOMParser. Your XML is never uploaded.

Latest from Our Blog

Tips, tutorials, and insights about web development