Skip to content
← Back

XML to JSON Online Converter

Data
Runs locally · Not uploaded

Free online XML ↔ JSON bidirectional converter with formatted output. Quickly convert data formats.

Was this result helpful?

For local tools, open DevTools → Network and search your input — it should not appear in requests.

Usage Guide

XML and JSON are the data languages of old and new systems: enterprise software, SOAP and some configs still speak XML, while modern APIs and front-ends only accept JSON. This tool converts both ways in the browser, with options for @-prefixed attributes, CDATA, array folding, and line-level validation errors.

1. Both directions

  1. XML → JSON: paste XML; child elements become keys, repeated siblings become arrays; attributes default to keys like @id, and CDATA lands under #cdata.
  2. JSON → XML: paste JSON; the same conventions restore attributes and CDATA; large integers are written as digit text when possible.
  3. On error, read the line:col badge: well-formedness validation is on, so mismatched tags surface instead of being silently accepted.

2. How to pick options

Turn off “Keep attributes” only when you truly want the element tree alone. “Wrap all elements as arrays” stabilizes shapes for strict schemas; or list local names in “Force-array tags” (e.g. role,item). For mixed content, enable “Keep text whitespace” so text lands under #text. External entities and entity expansion stay disabled to shrink the XXE surface.

3. Attributes versus elements: the biggest fork

XML can express one fact two ways: <item id="1"/> (attribute) and <item><id>1</id></item> (child element). This tool maps attributes to @id by default while child elements stay id — confirm naming rules with the consumer before shipping.

4. Three frequent traps

  • Inconsistent cardinality: a field that sometimes holds one value and sometimes many yields a scalar one time and an array the next — use force-array tags or wrap-all-arrays, or keep the source consistent.
  • Namespace prefixes: tags like ns:item carry the prefix into the key name; confirm de-prefixing with the other system.
  • Declaration versus actual encoding: when the encoding in <?xml version="1.0" encoding="..."?> disagrees with the content encoding, parsing fails outright.

FAQ

No. The XML/JSON structural conversion runs entirely in your browser — interface payloads, config samples, and the like go nowhere near a server.

Element attributes become keys with a special prefix (e.g., @ or -), and text content lands in a #text field; the naming rules are customizable to match different systems. After converting, spot-check this layer against the agreed contract rather than stopping at “it converted”.

Yes. Namespace prefixes are preserved, CDATA sections are handled properly, and complex formats like SOAP parse fine. Encoding and namespaces are the two items most worth verifying in cross-system work.

This is where conventions diverge most: a child that appears once may come out as an object under one convention and a one-element array under another; only repeated children are reliably inferred as arrays. Confirm the output shape with a short sample before processing long text, record the options in effect before batch runs, and re-run the same data after any change to catch silent drift.

Archive a success sample together with a failure sample, noting the data source, the conversion options, and what is not guaranteed, so context doesn't get lost in retelling. Hook into the JSON/XML formatters when you need to inspect structure, and keep a master copy you can roll back to.

Related Tools

Related Articles