Register Login

Difference between XML and JSON

JSON (JavaScript Object Notation), is an open-standard file format used for data interchange. It can store human-readable text. XML, on the other hand, is a well-known markup language that provides data in an organized and easy-to-understand manner.

It is case-sensitive and offers developers to establish markup elements and produce customized markup language. Both JSON & XML uses the same concept to transfer data from client to server and vice versa. In this article, you will learn about the difference between XML and JSON.

XML vs. JSON

JSON XML
It is abbreviated as JavaScript Object Notation. It is abbreviated as Extensible Markup Language.
It transmits the data in a parseable from client to server & vice versa. It sends the data in a structured format that the user can utilize to annotate metadata by parsing the script.
It depends on the JavaScript language. It got derived from SGML.
It uses curly braces to determine the start and stop of a data cluster. It uses user-defined opening and closing tags to determine the start and stop.
In JSON, there are less verbose. XML is verbose and uses more words to define the data context and the intention.
JSON does not allow defining the namespaces. XML supports defining namespaces.
JSON does not have the ability to display data. XML allows displaying data.
JSON is faster as compared to XML. XML is slower as compared to JSON.
The data structure used by JSON is a Map. It uses key-value pairing and becomes useful when interpretation and predictability are needed. XML uses a Tree data structure and follows a tree-like hierarchy of data representation. This data structure is responsible for making XML time-consuming and tedious.
It supports the concept of arrays. It doesn’t support arrays.
JSON files are easy to read in comparison to XML. XML documentations are relatively tough to read or interpret.
JSON is not that secure in terms of data security. XML is comparatively much secured than JSON.
Developers prefer JSON for data delivery between servers & browsers. Developers prefer XML for storing data on the server side.
JSON does not support commenting within its file. XML supports commenting.
JSON supports the UTF-8 encoding scheme only. XML supports various encoding schemes like UTF-8, UTF-16, US-ASCII, ISO-8859-1, Shift-JIS, ISO-10646-UCS-2, etc.
JSON came into occurrence in the year 2002, created by Douglas Crockford. XML came into occurrence in the year 1996 by W3C (World Wide Web Consortium).
JSON supports text & number data types only. XML supports various data types like numbers, text, graphs, images, charts, etc.

Example of JSON:

{
"firstName" : "Mr. Karlos",
"lastName" : "Ray"
"designation" : ["Researcher", "Author", "Security Engineer", "Programmer"] 
}

Example of XML:

<Employee>
<FirstName>Mr. Karlos</FirstName>
<LastName>Ray</LastName>
<Designation>
<Details>Researcher</Details>
<Details>Author</Details>
<Details>Security Engineer</Details>
<Details>Programmer</Details>
</Designation>
</Employee>