Free online XML ↔ JSON bidirectional converter with formatted output. Quickly convert data formats.
TL;DR: Free online XML and JSON bidirectional converter. Correctly handles attributes, namespaces, and CDATA, runs locally in your browser.
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
- XML → JSON: paste XML; child elements become keys, repeated siblings become arrays; attributes default to keys like @id, and CDATA lands under #cdata.
- JSON → XML: paste JSON; the same conventions restore attributes and CDATA; large integers are written as digit text when possible.
- 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
Online XML/JSON Converter: Convert Between Data Formats
Learn how to convert between XML and JSON: @-prefixed attributes, CDATA, array folding, and line-level parse errors for API and legacy integrations.
JSON vs XML: Data Format Comparison, Which Is Right for Your Project?
JSON is lightweight and JS-native, XML is strict with mature schema support. Compare the two formats on size, tooling, and typical use cases, and learn why XML refuses to die in specific domains.
Online JSON/YAML Converter: Convert Between Configuration Formats
Learn how to convert between JSON and YAML formats for configuration data. Understand the differences between JSON and YAML, and use cases in DevOps and configuration management.