XML and JSON are two different content types that are used for the interchange of data between different systems.

JSON is a javascript simple object model that contains key and value types. It is the lightweight data format used in REST API and Microservices. It is easily readable by humans and machines.

JSON simple example

const jsondata = {
"name": "john",
"email":"[email protected]"

XML is a start and end tag, and the validation is based on XML Schema. It provides many features, used in Service Oriented Architecture with SOAP Protocols. It is complex to understand humans.

Example xml

    <user id="1">

Difference between XML and JSON

XML contents contains type less dataJSON object c content typed data
Only Supported type is StringSupports types such as Array, String, Number, and Boolean
Browser support is limitedIt supports all browsers including latest
It is complex to serialize and deserialize in javascriptEasy to serialize and deserialize in javascript
Parsing and writing requires parserEasy to read and write with language
Format is based on schemaContains Key a nd value pair
Language supports popular languagesSupports all programming languages
Comments are supportedComments not supported