Extensible Markup Language (XML) is a text format derived from Standard Generalized Markup Language (SGML). Compared to SGML, XML is simple. HyperText Markup Language (HTML), by comparison, is even simpler. Even so, a good reference book on HTML is an inch thick. This is because the formatting and structuring of documents is a complicated business.

Most of the excitement around XML is around a new role as an interchangeable data serialization format. XML provides two enormous advantages as a data representation language:

  1. It is text-based.
  2. It is position-independent.

These together encouraged a higher level of application-independence than other data-interchange formats. The fact that XML was already a W3C standard meant that there wasn’t much left to fight about (or so it seemed).

Unfortunately, XML is not well suited to data-interchange, much as a wrench is not well-suited to driving nails. It carries a lot of baggage, and it doesn’t match the data model of most programming languages. When most programmers saw XML for the first time, they were shocked at how ugly and inefficient it was. It turns out that that first reaction was the correct one. There is another text notation that has all of the advantages of XML, but is much better suited to data-interchange. That notation is JavaScript Object Notation (JSON).

The most informed opinions on XML (see for example xmlsuck.org) suggest that XML has big problems as a data-interchange format, but the disadvantages are compensated for by the benefits of interoperability and openness.

JSON promises the same benefits of interoperability and openness, but without the disadvantages.

Let’s compare XML and JSON on the attributes that the XML community considers important.

From http://www.simonstl.com/articles/whyxml.htm


XML is simpler than SGML, but JSON is much simpler than XML. JSON has a much smaller grammar and maps more directly onto the data structures used in modern programming languages.


JSON is not extensible because it does not need to be. JSON is not a document markup language, so it is not necessary to define new tags or attributes to represent data in it.


JSON has the same interoperability potential as XML.


JSON is at least as open as XML, perhaps more so because it is not in the center of corporate/political standardization struggles.

From http://www.karto.ethz.ch/neumann/caving/cavexml/why_xml.html

In summary these are some of the advantages of XML.

XML is human readable

JSON is much easier for human to read than XML. It is easier to write, too. It is also easier for machines to read and write.

XML can be used as an exchange format to enable users to move their data between similar applications

The same is true for JSON.

XML provides a structure to data so that it is richer in information

The same is true for JSON.

XML is easily processed because the structure of the data is simple and standard

JSON is processed more easily because its structure is simpler.

There is a wide range of reusable software available to programmers to handle XML so they don’t have to re-invent code

JSON, being a simpler notation, needs much less specialized software. In the languages JavaScript and Python, the JSON notation is built into the programming language; no additional software is needed at all. In other languages, only a small amount of JSON-specific code is necessary. For example, a package of three simple classes that makes JSON available to Java is available for free from JSON.org.

XML separates the presentation of data from the structure of that data.

XML requires translating the structure of the data into a document structure. This mapping can be complicated. JSON structures are based on arrays and records. That is what data is made of. XML structures are based on elements (which can be nested), attributes (which cannot), raw content text, entities, DTDs, and other meta structures.

A common exchange format

JSON is a better data exchange format. XML is a better document exchange format. Use the right tool for the right job.

Many views of the one data

JSON does not provide any display capabilities because it is not a document markup language.

From http://www.softwareag.com/xml/about/xml_why.htm

Self-Describing Data

XML and JSON have this in common.

Complete integration of all traditional databases and formats

(Statements about XML are sometimes given to a bit of hyperbole.) XML documents can contain any imaginable data type – from classical data like text and numbers, or multimedia objects such as sounds, to active formats like Java applets or ActiveX components.

JSON does not have a <[CDATA[]]> feature, so it is not well suited to act as a carrier of sounds or images or other large binary payloads. JSON is optimized for data. Besides, delivering executable programs in a data-interchange system could introduce dangerous security problems.


XML and JSON both use Unicode.

Open and extensible

XML’s one-of-a-kind open structure allows you to add other state-of-the-art elements when needed. This means that you can always adapt your system to embrace industry-specific vocabulary.

Those vocabularies can be automatically converted to JSON, making migration from XML to JSON very straightforward.

From http://www.xmlspy.com/manual/whyxml.htm

XML is easily readable by both humans and machines

JSON is easier to read for both humans and machines.

XML is object-oriented

Actually, XML is document-oriented. JSON is data-oriented. JSON can be mapped more easily to object-oriented systems.

XML is being widely adopted by the computer industry

JSON is just beginning to become known. Its simplicity and the ease of converting XML to JSON makes JSON ultimately more adoptable.

Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

No Responses to “JSON VS XML”

Leave a Reply:

Name (required):
Mail (will not be published) (required):
Comment (required):
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>