HomeToolsDeveloper Tools › XML to JSON Converter

XML to JSON Converter — Convert XML Online, Free

Convert XML to JSON instantly. Server-side parsing handles files up to 20 MB, CDATA sections, and malformed XML with clear error messages. No signup required.

Processed on our server — your XML is never stored or logged.
XML Input 0 chars
Upload .xml file
JSON Output
JSON output will appear here

XML to JSON Converter transforms XML documents into JSON instantly. Paste any XML — an API response, configuration file, SOAP payload, RSS feed, or export — into the left pane and click Convert to JSON. The tool parses your XML server-side using PHP's SimpleXML extension and returns formatted JSON in the right pane, which you can copy or download as a .json file.

Three conversion options give you control over the output structure. Pretty-print (checked by default) formats the JSON with 2-space indentation for readability. Preserve attributes includes XML element attributes in the output under @attributes keys — useful when your XML uses attributes to carry meaningful data, not just metadata. Force arrays wraps the root output in a JSON array, giving you a predictable structure regardless of how many root elements the XML contains.

CDATA sections are handled transparently. The parser uses the LIBXML_NOCDATA flag, which converts CDATA content into regular text nodes — the content appears as a plain string in the JSON output rather than being wrapped or discarded.

When your XML has errors, the tool returns a parse error table instead of a generic error message. Each row shows the exact line number, column number, and libxml error message, so you can find and fix the problem without guessing where it is. This makes the tool useful both for converting valid XML and for debugging malformed XML from external sources.

Processing runs entirely server-side with a 256 MB memory limit, which means files this large cannot be processed in browser-only tools. Nothing is written to disk or retained after the response is sent. No account or session tracking is used.

Use Cases

Converting REST API XML responses

A developer integrates with a legacy API that returns XML. They paste the raw XML response into the converter and get back formatted JSON, which they can paste directly into a JSON validator or formatter to check the structure before writing parsing code.

Processing SOAP payloads

A backend engineer needs to inspect the content of a SOAP response during debugging. Uploading the .xml file and converting it to JSON makes the nested structure immediately readable — without having to write XPath queries or set up a SOAP client.

Transforming RSS and Atom feeds

A product developer wants to work with an RSS feed in a JavaScript application that expects JSON. They convert the feed XML to JSON here, inspect the output structure, then write their parser against the JSON representation — much easier than parsing XML directly in the browser.

Migrating configuration files

A DevOps engineer is migrating a legacy app from XML-based configuration (like Maven pom.xml or Spring XML) to a JSON-based system. Converting the XML to JSON gives them a starting point to restructure and clean up, rather than rewriting from scratch.

Debugging XML imports

A data engineer receives an XML export from a CRM or ERP that fails to import into a new system. They upload the file and inspect the parse error table — line number, column, and message — to find the malformed element causing the failure, without needing to open the file in an XML editor.

Frequently Asked Questions

How does the XML to JSON converter work?

Paste your XML into the left pane (or upload a .xml file up to 20 MB) and click Convert to JSON. The tool parses your XML server-side using PHP's SimpleXML extension with CDATA support and encodes the result as JSON. The output appears in the right pane, ready to copy or download.

Is the XML to JSON conversion free?

Yes — completely free. No account, no watermark, no usage cap. Your XML is processed on our server and discarded immediately. Nothing is stored or logged between requests.

What does "Preserve attributes" do?

XML elements can have attributes in addition to text content — for example <item id="1">. When Preserve attributes is enabled, element attributes are included in the JSON output under an @attributes key, matching the most common XML-to-JSON convention. When disabled, only text content and child elements are included.

What is "Force arrays" mode?

SimpleXML represents a single child element as a JSON object and multiple children of the same name as a JSON array. Force arrays wraps the root output in an array, which is useful when you need a predictable array structure regardless of how many root elements the XML contains.

Can I convert large XML files?

Yes. The tool supports XML files up to 20 MB, which covers most real-world API responses, SOAP payloads, export files, and configuration documents. Processing runs server-side with a 256 MB memory limit — browser-only tools cannot process files this large.

What happens if my XML has errors?

If your XML cannot be parsed, the tool shows a parse error table listing each problem with its line number, column number, and error message from libxml. This lets you pinpoint and fix the issue, unlike tools that just show "invalid XML" without location information.

Does this handle CDATA sections?

Yes. The parser uses the LIBXML_NOCDATA flag, which converts CDATA sections into regular text nodes. CDATA content appears as a plain string in the JSON output rather than being wrapped or discarded.

Related Tools