Convert XML to JSON

Paste your XML code below

How It Works

  1. Paste your XML code
  2. Toggle pretty-print option
  3. Click Convert
  4. Copy or download the JSON

Features

  • Preserves attributes
  • Handles nested elements
  • Pretty-print toggle
  • Text node support

Your text is processed entirely inside your browser.

Related Tools

JSON Formatter

Format and validate your JSON data.

HTML Validator

Check your HTML code for errors.

Text Cleaner

Remove extra spaces and formatting.

Frequently Asked Questions

How does the XML to JSON converter work?

It uses the browser's built-in DOMParser to parse XML, then recursively traverses the DOM tree to build a JSON object, preserving elements, text, attributes, and nesting.

Are XML attributes included in the JSON output?

Yes. XML attributes are included in the output as properties prefixed with @ to distinguish them from child elements.

Is my data uploaded to a server?

No. All processing happens entirely in your browser. Your code never leaves your device.

Can I toggle pretty-printing?

Yes. A pretty-print toggle lets you choose between compact or formatted JSON output with indentation.

Read Guide: XML to JSON Conversion