DockittDockitt

XML to JSON Converter — Free Online Tool

Convert XML to JSON format online. Handles attributes, nested elements and CDATA. Free, browser-based.

Runs entirely in your browser — no data leaves your device
No account, no signup, completely free
Instant results — no waiting for server processing
Works offline once the page is loaded
Runs entirely in your browser. Your text never leaves your device — no server, complete privacy.

XML was the dominant data interchange format before JSON took over in web APIs. This tool converts XML documents to JSON using the browser's built-in DOMParser to parse the XML, then recursively walks the DOM tree to build a JavaScript object. Attributes are included as properties prefixed with '@', text content is stored as a '#text' property, and nested elements become nested JSON objects. The output is prettily formatted and ready to copy or download.

How to use

  1. Paste your XML document into the input textarea.
  2. Click 'Convert to JSON' to parse the XML and generate the JSON output.
  3. Copy the JSON to clipboard or download it as a .json file.

FAQ

How are XML attributes converted to JSON?

XML attributes are included in the JSON output as properties prefixed with the '@' character. For example, <person id='1' name='Alice'> is converted to {"@id": "1", "@name": "Alice", ...}. This convention is widely used in XML-to-JSON converters and clearly distinguishes attributes from child element properties.

How are text nodes and mixed content handled?

If an element contains only text (no child elements or attributes), the JSON value is the text string itself. If an element has both text content and child elements or attributes, the text content is stored as a '#text' property alongside the other properties. CDATA sections are treated as text content.

What happens when there are multiple sibling elements with the same tag name?

When multiple sibling elements share the same tag name, they are collected into a JSON array under that tag name. For example, <items><item>a</item><item>b</item></items> is converted to {"items": {"item": ["a", "b"]}}. This is the most natural JSON representation of repeated XML elements.

Is the XML namespace preserved in the JSON output?

XML namespace prefixes are preserved in the property names (e.g., 'ns:element' becomes an 'ns:element' key in JSON), but namespace URI declarations (xmlns attributes) are included as regular '@xmlns' properties. Full namespace resolution is not performed — the output reflects the raw XML structure.

What XML features are not supported?

Processing instructions (<?...?>) and XML comments (<!-- -->) are not included in the JSON output. DOCTYPE declarations are ignored. The XML declaration (<?xml version='1.0'?>) is also excluded. Only element nodes, attribute nodes, and text/CDATA nodes are converted.

Is the conversion done in my browser or on a server?

The conversion runs entirely in your browser using the built-in DOMParser API. Your XML is never sent to any server. This is important for XML files that may contain proprietary business data, configuration files, or other sensitive content.