What is the difference between JSON and XML?

XML and JSON are the two most common formats for data exchange. Although both can be used to receive data from a web server, there are differences between the two. This time we will discuss the difference between JSON and XML.

XML (Extensible Markup Language) has been around for over 3 decades and is part of every web application. Whether it’s a configuration file or a mapping document. XML facilitates the exchange of data, providing a clear data structure and helping with dynamic configuration and variable loading!

JSON stores all data in a map (key / value) format, which is tidy and easier to understand. Many people claim that JSON is slowly replacing XML because of several advantages, such as ease of data modeling or direct mapping to object domains, more predictability, and an easy-to-understand structure. But there are also developers who have used both, I don’t completely agree with that! In this article, you will learn the difference between JSON and XML in detail.

Read also: What is the difference between Java and JavaScript?

The difference between JSON and XML

For starters, JSON is just a data format, while XML is a markup language. XML is used to store and transport data from one application to another over the Internet. JSON, on the other hand, is an easy data exchange format that makes it much easier for your computer to analyze the data that is being sent.

The JSON format is self-describing and comparatively much easier to read than XML documents. However, if a project requires tagging documents and metadata information, it’s best to use XML.

What is JSON?

JSON used to store information in an organized and easily accessible way. Its full form is JavaScript Object Notation. Provides a human-readable logical data set. The JSON file extension is .json.

JSON history

The data format was first defined by Douglas Crockford in March 2001, in real time. Server-to-browser communication protocol without the use of browser plug-ins, such as Flash or Java applications. The official website was launched in 2002, and in 2005 Yahoo began offering JSON web services. It soon became the international ECMA standard in 2013. Finally, the latest JSON format standard was published in 2017.

JSON feature

  • Easy to use – The JSON API provides a high-level frontend, which helps you simplify usage.
  • Performa – JSON is quite fast because it uses very little memory space, which is very suitable for system or large object graphics.
  • Free tools – The JSON library is open source and free.
  • No need to map – The Jackson API provides default mapping for many objects to be serialized.
  • Clean JSON – Creates a clean and compatible JSON output that is easy to read.
  • No addiction – JSON library does not require another library for processing.

The advantages of JSON

  • Accepts all browsers.
  • Easy to understand.
  • The syntax is very easy.
  • It can be parsed in JavaScript using the eval () function.
  • Creating and manipulating is easy.
  • All major JavaScript frameworks support JSON support.
  • Most backend technologies support JSON.
  • The transmission and serialization of structured data is done using a network connection.

Missing JSON

  • JSON offers poor extensibility because there is no support for the namespace.
  • Limited support for development tools.
  • Provides support for formal grammatical definitions.

What is XML?

XML is a markup language designed to store data. It is a popular use or data transfer. Case sensitive. XML allows you to define markup elements and generate a custom markup language. The basic units in XML are known as elements. The XML file extension is .xml.

Read also: What is an XML file and how do you open it?

XML history

This is an SGML application. XML was compiled by a working group of eleven members who never met face to face. The design was made using a combination of weekly teleconferencing and email. The first version was released between August and November 1996 on Sun Microsystems, and the first version of XML was released in February 1998.

XML features

  • XML tags are not predefined. You must define a custom label.
  • XML is designed to carry data, it does not allow you to display that data.
  • XML markup code is easy for people to understand.
  • The structured format is easy to read and write from the program.
  • XML is an extensible markup language like HTML.

The advantages of XML

  • With the help of XML, data exchange is done quickly between different platforms. So this makes the document mobile between systems and applications.
  • XML separates data from HTML
  • XML simplifies the process of changing the platform.

Missing XML

  • XML requires application processing.
  • XML syntax can sometimes be confusing because it is similar to other alternatives.
  • No support for intrinsic data type.
  • XML syntax is redundant.
  • It does not allow the user to create their own label.

JSON Code vs. XML Code

JSON code example:

  "siswa": [ 
        "nama": "Tom", 
        "jurusan": "IPA" 
        "nama": "Niki", 
        "jurusan": "IPS" 

XML code example:

<?xml version="1.0" encoding="UTF-8" ?>


We have seen how JSON and XML have their advantages and disadvantages. Let’s summarize the above points as we understand more of the differences between JSON and XML

Parameter XML (Extensible Markup Language) JSON (JavaScript Object Notation)
Language XML is a markup language, not a programming language, that has tags to define elements. JSON is a JavaScript-only format.
Data storage XML data is stored as a tree structure. The data is stored as a map with key value pairs.
Processing Can process and format documents and objects. It does not do any processing or calculations
Speed Large and slow in analysis, causing slower data transmission Very fast due to very small file size, faster parsing by JavaScript engine, and therefore faster data transfer
Namespace support Accepts namespaces, comments, and metadata There is no provision for namespaces, adding comments, or writing metadata
Document size The size of the documents is large and with large files, the structure of the labels makes them large and difficult to read. Concise and easy to read, with no unused or blank labels or data, keep your files simple.
Matrix support Does not directly accept arrays. In order to use an array, you must add a label for each item. Supports accessible matrix
Data type Support It supports many complex data types, including charts, charts, and other non-primitive data types. JSON only supports strings, numbers, Boolean arrays, and objects. Even objects can contain only primitive types.
UTF support XML supports UTF-8 and UTF-16 encodings. JSON supports UTF and ASCII encoding.
Security XML structures are vulnerable to multiple attacks because external entity extension and DTD validation are enabled by default. If disabled, the XML parser is more secure. JSON analysis is safe most of the time, unless JSONP is used, which can lead to Cross-Site Request Forgery (CSRF) attacks.
Data processing Although X in AJAX means XML, due to XML tags, a lot of bandwidth is wasted, which makes AJAX requests slow. Because the data is processed in series in JSON, its use with AJAX ensures faster processing and is therefore preferable. Data can be easily manipulated using the eval () method.


So this is the difference between JSON and XML. We can say that JSON and XML are ways to organize our data in a format that many programming languages ​​and APIs can understand.

The bottom line is that if you have a simple data exchange that doesn’t bother with semantics and validation, choose JSON. However, it is also important that you continue to learn XML and related technologies to do more than just exchange data and process quickly.

So many articles The difference between JSON and XML. Looking forward to more interesting articles and don’t forget to share this article with your friends. Thanks…

Leave a Comment