JSON vs XML

JSON for interfaces between programs, XML where a schema has to be enforced.

Choose JSON when

Web APIs and configuration. Less punctuation, native in every browser, and it maps directly onto the data structures programs already use.

Choose XML when

Documents and regulated exchange, where namespaces, attributes and a validating schema are the point rather than overhead.

The thing that catches people out

The two are not interchangeable. XML distinguishes attributes from elements and JSON has no such thing, so a round trip through JSON quietly flattens that distinction.

Side by side

JSONXML
Full nameJavaScript Object NotationExtensible Markup Language
Extension.json.xml
Media typeapplication/jsonapplication/xml
CompressionUncompressedUncompressed
This site can write itYesYes

Decided? Convert it here