XML to JSON

Paste XML and it converts to JSON automatically — nothing leaves your browser.

XML Input 0 lines
1
JSON Output 0 lines
1
UTF-8 · 0 B XML → JSON
Waiting for input

How It Maps

  • Attributes become @name keys
  • Repeated tags become arrays
  • Mixed text uses a #text key
  • Instant conversion as you paste
  • Copy or download the result

Features & Supported Capabilities

  • Detects and reports invalid XML before converting
  • Preserves nested structure exactly
  • Handles files up to 10 MB
  • Optional line wrapping for long output
  • Runs entirely in your browser — nothing uploaded

About this XML to JSON converter

Converting XML to JSON is a common step when moving data from SOAP services, legacy systems and feeds into modern JavaScript and REST APIs. This free online XML to JSON converter maps elements to objects, turns repeated elements into arrays, keeps attributes and preserves text content, so the structure of your data carries over.

The conversion runs in your browser and nothing is uploaded. If you need the reverse, use JSON to XML. To tidy the XML first try the XML formatter, and to check the result use the JSON formatter or JSON viewer.

Frequently Asked Questions

Everything you might want to know about the online XML to JSON converter.

Each XML element becomes a JSON object key. The root element wraps everything, and the conversion follows a small set of consistent rules for attributes, repeated elements, and text content.
Yes. Each attribute becomes a JSON key prefixed with @, e.g. <book id="1"> becomes "@id": "1", so attributes stay distinguishable from child elements.
Sibling elements that share the same tag name become a JSON array, so <book>...</book> repeated three times under <library> becomes a "book": [...] array of three items.
No. The conversion runs entirely in your browser. Your XML is never uploaded, stored, or logged.
Yes, use the JSON to XML tool, which follows the same @attr / array / #text conventions in reverse.
You can paste text or upload a file up to 10 MB.
If an element has only text and no children or attributes, it becomes a plain JSON string. If it also has attributes or child elements, its own text is kept under a "#text" key alongside them.
Yes. Use the Copy button to copy it to your clipboard, or Download to save it as a .json file.
Yes. The XML is parsed first, so a well-formedness error is reported with a line and column instead of producing incorrect JSON.