XJ

XML to JSON

Convert XML into structured JSON

Data Format
🔒 100% client-side — your data never leaves this page
Maintained by Evan•Updated: November 1, 2026
Options
Input

Paste XML first to convert it into JSON and inspect the structure immediately.

Output
Converted JSON will appear here
🔒 Processed locally in your browser
Page reading mode

About this tool

Map pasted XML to JSON using the browser XML parser. Attributes use @attributes, attributed leaf text uses #text, and repeated sibling names form arrays. Leaf values remain strings. Direct text in mixed-content parents and XML formatting are not preserved, so inspect the result before using it for data migration. Parsing and display happen locally.

Examples

Compare leaf CDATA with mixed parent text

text

Input XML:
<r id="7"><x>1</x><x><![CDATA[2]]></x><p>before <b>bold</b> after</p></r>

Output JSON, compacted here:
{"r":{"@attributes":{"id":"7"},"x":["1","2"],"p":{"b":"bold"}}}

The parent text "before" and "after" is omitted.

Common Mistakes and Fixes

A valid JSON result is treated as a complete XML archive

Cause: The mapping groups same-named siblings, trims leaf text, and omits mixed parent text, comments, and lexical CDATA boundaries. It does not retain every node’s original order.

Fix: Keep the XML source for archival or round trips. Use this mapping to inspect simple data-oriented XML, then verify the receiving application’s expected field structure.

Frequently Asked Questions

How are attributes, text, and repeated tags mapped?

The root tag is retained. Attributes go under @attributes; a text-only leaf becomes a string, while an attributed leaf uses #text. Repeated sibling tag names become arrays. Numeric-looking values remain strings.

Is all XML content preserved?

No. Text and CDATA inside a leaf become trimmed text. When an element has child elements, its direct mixed text is omitted; comments, CDATA boundaries, and ordering between differently named siblings are not retained. This is not a reversible XML representation.

Does the tool fetch or execute the XML?

It parses pasted text locally with the browser’s XML parser and displays JSON text. It does not send an API request or perform SOAP, DTD, or XSD validation.

Keep browsing