Home/XML to JSON Converter

XML to JSON Converter – Convert XML & JSON Online Free

4.1 Rating from 127 people who voted
Share this page
XML to JSON Converter Bidirectional conversion with attribute handling
Supports nested elements, attributes (converted to @attributes), arrays, CDATA, and text content. Invalid syntax is caught and highlighted.
Conversion Result

About the XML to JSON Converter

The XML to JSON Converter works in both directions: paste in XML and get clean, structured JSON, or paste in JSON and get well-formed XML back. It handles nested elements, arrays, and attributes automatically, converting XML attributes into an @attributes object so no data is lost during conversion.

It’s built for developers working with API responses, configuration files, or legacy data feeds that need to move between formats. Once your XML is converted, the JSON Formatter can help you validate and beautify the result, and the JSON to CSV Converter is useful if you need to move that data into a spreadsheet.

Our team tested this converter against deeply nested XML trees, repeated sibling elements, CDATA sections, and malformed input to confirm both conversion directions produce accurate, predictable output.

How to Use the XML to JSON Converter

  • Choose a direction: XML → JSON or JSON → XML.
  • Paste your XML or JSON into the input field.
  • Enable Pretty Print Output if you want indented, human-readable formatting.
  • Click Convert to generate the result instantly.
  • Use Copy Output or Download to save the converted file.

Example Usage

Input (XML to JSON): <person><name>John</name><age>30</age></person>

Output:

{ “person”: { “name”: “John”, “age”: 30 } }

If your XML includes attributes, such as <person id="1">, the converter nests them under an @attributes key in the resulting JSON, and converts them back into proper XML attributes when going the other direction. If you’re working with data instead of markup, the CSV to JSON Converter handles tabular sources the same way.

Frequently Asked Questions

Each element’s attributes are placed inside an “@attributes” object within that element’s JSON node, keeping them separate from child elements and text content.

The converter requires a single root element to build valid XML, so JSON with multiple top-level keys will return an error asking you to wrap your data under one root key.

Yes, when multiple XML elements share the same tag name at the same level, they’re automatically converted into a JSON array to preserve the order and count of each item.

Yes, values like “true”, “false”, and numeric strings are automatically cast to boolean and number types in the JSON output instead of staying as plain text.

Yes, it’s completely free with no signup required.