Initializing, please wait a moment

Paste XML into the left pane and click Convert. The matching JSON appears on the right, ready to copy. Nothing is uploaded - the conversion happens in your browser.

How to convert XML to JSON

  1. Paste or type your XML into the input box on the left.
  2. Click Convert (conversion also runs as you type).
  3. Read the JSON on the right; tick Compact output for a single-line result.
  4. Click Copy Output to put the JSON on your clipboard.
Input: bytes
Output: bytes

XML to JSON Converter


Paste an XML document into this XML to JSON converter and it returns the same data as formatted JSON. Element names become keys, attributes are prefixed with @_, and repeated tags become arrays. Everything runs in your browser, so the XML never leaves your device and no account is needed.

What the converter preserves

The browser's own DOMParser reads your XML, so the structure survives the round-trip the way most JSON consumers expect:

  • Attributes are kept, not dropped. An element like <book id="1"> becomes "book": { "@_id": "1" }, so downstream code can still read the id.
  • Mixed content stays addressable. When an element holds both attributes and text, the text lands under a #text key.
  • A single child tag becomes an object; two or more siblings with the same tag name become a JSON array, which is what list-shaped data needs to iterate cleanly.

When to reach for it

Use it when a downstream service, config loader, or API accepts JSON but you were handed XML - a legacy SOAP response, an RSS item, an Android layout, or a Maven POM. Toggle Compact output when you want a single minified line to drop straight into code.

Malformed markup is reported, not guessed

Because the parser is the browser's own DOMParser, malformed markup is reported back to you instead of producing silent, wrong output. Fix the highlighted issue and convert again.

← Back to Developer Tools

Related tools:

  • MD5 converter - Text to MD5 + MD5 to text cached lookup.
  • Convert PDF to TEXT online - Extract text from PDF online for copying and editing.
  • Text To HTML Editor - Text to HTML editor online - write in a WYSIWYG view and watch the generated HTML update live, with
  • CSS Gradient Animator Generator - CSS gradient generator - build animated linear gradients with live preview; copy ready-to-paste CSS
  • CSS Minifier - Minify CSS online for faster page loads.
  • CSS UnMinifier - CSS unminifier online - beautify minified CSS with proper indentation, line breaks, and readable
  • JavaScript Minifier - JavaScript minifier online free - paste your JS, click Minify, and copy the compressed code.
  • JSON Parser By Tree View - Paste JSON to validate, format, and view it in a tree.
  • JavaScript UnMinifier - JavaScript unminifier online - reformat minified JS with indentation and line breaks for
  • Keyboard Test - Press each key - the on-screen layout highlights it.
  • Text Diff - Compare code, text, or HTML online, side by side.
  • Developer Tools - Developer tools to parse JSON, minify or unminify CSS/JS, compare text, and generate MD5 hashes.

Tags: #developer

Related guides:

Related news:

Loading reviews...

Frequently Asked Questions

Is my XML uploaded to a server?

No. The conversion uses the browser's built-in DOMParser and runs entirely on your device. The XML you paste is never sent anywhere, which makes the tool safe for internal or confidential data.

How are XML attributes represented in the JSON?

Each attribute becomes a key prefixed with @_ on the element object. For example, <user role="admin"> converts to "user": { "@_role": "admin" }. This keeps attributes distinct from child elements.

What happens when a tag repeats?

Two or more sibling elements with the same tag name are grouped into a JSON array. A single occurrence stays an object, so simple structures do not get wrapped in arrays unnecessarily.

Where does element text go?

A text-only element becomes a plain string value. When an element has both attributes and text, the text is stored under a #text key alongside the @_ attribute keys.

What if my XML is invalid?

The output pane shows the parser error message instead of guessing. Correct the reported issue - a missing closing tag or an unescaped & is common - then convert again.

Can it convert JSON back to XML?

This page only converts XML to JSON. For the reverse direction, see the related tools listed below the tool.