DevPik Logo

XML to JSON Converter

Convert XML to JSON and JSON to XML online. Bidirectional converter with attribute handling, array detection, and file download.

How to Use XML to JSON Converter

  1. Paste your XML into the left input panel. The tool converts it to JSON in real-time as you type.
  2. Adjust options: choose attribute prefix (@, _, or none), select indentation (compact, 2, or 4 spaces).
  3. Click the Swap button to switch to JSON → XML mode and convert JSON back to XML.
  4. Upload XML or JSON files directly using the Upload button, or drag and drop.
  5. Copy the output to your clipboard or download it as a .json or .xml file.

About XML to JSON Converter

The XML to JSON Converter is a free online tool that converts between XML and JSON formats instantly. XML (eXtensible Markup Language) and JSON (JavaScript Object Notation) are the two most widely used data interchange formats. XML is common in enterprise systems, SOAP APIs, RSS feeds, SVG files, and Android configurations, while JSON dominates REST APIs, web applications, and modern config files. This bidirectional converter handles XML attributes (mapped with configurable prefixes like @ or _), nested elements, repeated elements (auto-detected as arrays), CDATA sections, self-closing tags, and mixed content. The JSON to XML mode generates well-formed XML with optional XML declarations and customizable root element names. Everything runs 100% client-side in your browser — your data never leaves your device.

Frequently Asked Questions

How do I convert XML to JSON?

Paste your XML into the left input panel and the tool instantly converts it to JSON in the right panel. XML attributes are prefixed with @ by default (customizable), repeated child elements become arrays, and text content is preserved. Copy or download the result when ready.

How does the converter handle XML attributes?

XML attributes are converted to JSON properties with a configurable prefix. By default, an attribute like category="fiction" becomes "@category": "fiction" in JSON. You can change the prefix to underscore (_) or remove it entirely.

Can I convert JSON to XML?

Yes! Click the Swap button to switch to JSON → XML mode. Paste JSON in the left panel and get well-formed XML output. Properties prefixed with @ or _ are converted back to XML attributes. You can customize the root element name and toggle the XML declaration.

How are repeated XML elements handled?

Repeated child elements with the same tag name are automatically detected and converted to JSON arrays. For example, multiple <item> elements inside a parent become a JSON array. This auto-detection works at every nesting level.

Does the converter handle CDATA sections?

Yes. CDATA sections in XML are extracted and their content is included as text in the JSON output. The CDATA wrapper is removed since JSON doesn't have an equivalent concept.

What is the difference between XML and JSON?

XML uses tags with opening/closing elements and supports attributes, namespaces, and comments. JSON uses key-value pairs with a simpler syntax. JSON is more compact and easier to parse in JavaScript, while XML offers more metadata capabilities through attributes and schemas like XSD.

Is my data safe when converting?

Yes. This XML to JSON converter runs 100% client-side in your browser. No data is ever transmitted to any server. You can safely convert sensitive XML or JSON data.

Related Tools

Was this tool helpful?