ToolChop

XML to JSON Online

Convert XML ↔ JSON privately, in your browser. Attributes, text nodes, and repeating elements handled.

·

How to convert XML to JSON online

Paste your XML into the Input box. The parser uses the browser's built-in DOMParser, so any well-formed XML — namespaces, CDATA, attributes, mixed content — converts correctly. Attributes become keys prefixed with @; text content next to elements appears under a #text key. Both prefixes are configurable. Toggle the Direction switch to convert JSON back to XML.

Why a local XML converter matters

Most XML payloads people convert online are SOAP responses, B2B trade documents, configs, or compliance reports. Server-based converters log every payload they receive. ToolChop runs the entire conversion in your browser, so the XML never leaves your device.

What you can do

Frequently asked questions

How do I convert XML to JSON online for free?

Paste your XML into the Input box on the left. JSON appears on the right instantly. The conversion uses the browser's built-in DOMParser, so it accepts any well-formed XML — namespaces, attributes, CDATA, mixed content. Click Copy or Download.

Does ToolChop upload my XML?

No. The parser runs in your browser via DOMParser. Your data never leaves your device — there is no upload, no temporary storage, and no copy on our servers. That matters when the XML contains SOAP responses, configs, or anything internal.

How are XML attributes represented in JSON?

Attributes appear as keys prefixed with `@` by default (configurable). So `<book id="1">` becomes `{ "@id": "1" }`. This preserves the distinction between attributes and child elements when round-tripping back to XML.

How are repeating XML elements handled?

When a parent has multiple children with the same tag name, those children collapse into a JSON array. A single child stays a scalar/object. This matches the Badgerfish and similar XML-to-JSON conventions used by most parsers.

What about mixed content (text + child elements)?

Text content adjacent to child elements appears as a `#text` key inside the same object (configurable). Pure-text nodes (no attributes, no siblings) collapse directly to the string value to keep the JSON compact.

Can I convert JSON back to XML?

Yes — toggle the Direction switch to JSON → XML. The tool reads the top-level object key as the root element name, then recursively converts. Keys prefixed with `@` become attributes; `#text` becomes inline text; arrays become repeated elements.

What if my JSON has more than one top-level key?

XML requires a single root element, so JSON → XML expects exactly one top-level key. If your JSON has multiple top-level keys, wrap them in a root object first: `{ "root": { ...your data... } }`.

Are XML namespaces preserved?

Namespaced element names are preserved as-is (the `xmlns:` and `prefix:` appear in the JSON keys). Round-tripping namespaces works for most documents. For heavy XSD-validated XML where the exact namespace context matters, a dedicated XSLT/XSD pipeline is more appropriate than a generic converter.

Does the type-coerce option affect XML output?

Only when coming back from JSON — booleans, integers, and floats are written as their string representations inside XML elements. XML has no type system, so numeric or boolean information is purely conventional.

Is there a file size limit?

Only your browser's memory. DOMParser handles 10-MB+ XML documents in modern Chrome and Safari without issue. Past that, the textarea UI itself starts to lag. For very large XML use a CLI like xmlstarlet or jq.

Why is my XML failing to parse?

Most common causes: unescaped `&`, `<`, or `>` inside text content; mismatched closing tags; missing XML declaration. The error pane shows the engine's exact message. Escape `&` to `&amp;`, `<` to `&lt;`, and ensure every tag has a matching closer (or is self-closing).

Why use ToolChop instead of an online XML converter that uploads my data?

Privacy. Server-based converters log every payload, which is a problem when the XML contains SOAP requests, internal configs, or B2B trade data. ToolChop runs the converter in your browser via the standard DOMParser — the data never leaves your machine.

Runs in your browser Free forever No signup required Files never uploaded
Advertisement

More free tools