XML → JSON Converter

Convert XML to a JSON object — attributes become @keys

XML input

JSON output

Attributes → @attr, text content → #text, repeated tags → arrays.

Free Online Tool

XML → JSON Converter — Complete Guide & Instructions

MakeCard XML → JSON Converter transforms XML documents into readable JSON objects with a clear, predictable mapping: element attributes become "@key" properties, text content becomes "#text", and repeated sibling tags become arrays. The conversion runs on the browser's DOMParser, so even large XML stays on your machine. It is built for developers migrating APIs, inspecting config files, or feeding XML data into JSON-only tooling.

How to Use XML → JSON Converter

  1. 1 Paste your XML into the left "XML input" box — or click "Load sample" to try it.
  2. 2 Press "Convert →" to parse and transform the document.
  3. 3 Invalid XML is caught with an error message — fix unclosed tags and retry.
  4. 4 Read the pretty-printed JSON in the right panel: attributes appear as @keys, text as #text.
  5. 5 Click "Copy" to put the JSON on your clipboard.

Key Features & Capabilities

  • Attributes convert to @-prefixed keys — @id, @class etc.
  • Element text maps to #text so mixed content stays unambiguous.
  • Repeated sibling tags automatically become JSON arrays.
  • Pretty-printed output with 2-space indentation.
  • Real XML parsing via DOMParser — malformed input is rejected with a message.
  • Sample document loader and one-click JSON copy.

Supported Formats & Specifications

Parameter Specification
Parser Browser DOMParser (application/xml)
Attribute mapping name="v" → "@name": "v"
Text mapping Element text → "#text"
Repeated tags Sibling elements → JSON arrays
Output JSON with 2-space indent + copy button

Practical Everyday Use Cases

  • Migrating a legacy XML API response into JSON for modern consumers.
  • Inspecting Android layouts, RSS feeds or sitemap.xml as structured data.
  • Converting config files (pom.xml, web.config) into JSON for scripting.
  • Preparing XML sample data for tools that only accept JSON.
  • Teaching how XML structure maps onto JSON objects.

Pro Tips for Best Results

  • Repeated tags become arrays — accessing JSON safely means checking Array.isArray when a tag may appear once or many times.
  • Text-only elements collapse to a plain string — only elements with attributes or children produce objects.
  • Namespaces are treated as part of the tag name by DOMParser — strip them beforehand if your pipeline needs clean keys.
  • Use the Load sample button to learn the mapping before converting your own data.

Common Problems & Solutions

The document failed DOMParser validation — look for unclosed tags, missing root element, or unescaped & characters and fix them first.

XML has no types — every value converts as a string. Cast to number in your application code after parsing.

CDATA sections are read as text content; heavily nested mixed content may need manual review of the #text fields.

Privacy & Security

100% Client-Side Execution

Parsing and conversion run entirely in your browser via DOMParser — your XML never leaves the device and is not logged or stored.

No server uploads No data logging Safe for personal documents
FAQ Section

Frequently Asked Questions

Everything you need to know about using XML → JSON Converter

Paste the XML into the input box and press Convert — the tool parses it and emits a JSON object where attributes become @keys, text becomes #text and repeated tags become arrays.

The @ prefix distinguishes attributes from child elements with the same name — <item id="1"> becomes {"@id": "1"} so it cannot clash with an <id> child tag.

JSON objects preserve insertion order in practice, and children are converted in document order — repeated tags appear in arrays in the same order as the XML.

Not directly in this tool — the @/# conventions are designed for one-way conversion. For XML↔JSON round-trips use a dedicated library that tracks attributes separately.

Related FreeToolsBazaar Tools

Ready to Use XML → JSON Converter?

100% free, browser-based, and private. No installation, registration, or file upload to external servers required.

Start Using XML → JSON Converter