Home » Uncategorized » CSV vs XML vs JSON – Which is the Best Response Data Format?

CSV vs XML vs JSON – Which is the Best Response Data Format?

Whether or not you’re constructing a skinny shopper (net software) or thick shopper (shopper-server software) sooner or later you’re in all probability making requests to an internet server and wish a great knowledge format for responses. As of as we speak, there are three main knowledge codecs getting used to transmit knowledge from an internet server to a shopper: CSV, XML, and JSON. As a way to develop an software with a strong structure, it is a good suggestion to know the variations between every format and know when to make use of them. The aim of this submit is to outline every knowledge format, lay out the professionals and cons for every, and uncover which conditions work greatest with every format.


CSV stands for “comma separated values”. Because the identify implies, this knowledge format is principally an inventory of parts separated by commas. As an example that your response is sending again an inventory of individuals in a specific household. The format would seem like this:


Execs – This format is probably the most compact of all three codecs. Usually talking, CSV codecs are about half the dimensions of XML and JSON codecs. That is the main benefit of CSV as a result of it may assist scale back bandwidth

Cons – This format is the least versatile of all three codecs. It’s because a do-it-yourself parser is required to transform the CSV knowledge right into a native knowledge construction. Consequently, if the info construction modifications, there’s an related overhead of getting to vary and even redesign your parsers. Moreover, because the program creating the CSV and this system parsing the CSV reside on totally different machines (keep in mind that we’re passing knowledge from one machine to a different) then each packages have to be up to date concurrently to stop the receiving program to crash. In any other case, an outage is required to replace each packages individually to stop incompatibility points.

Lastly, CSV does not likely help knowledge hierarchies. What for those who needed to ship again attributes for every individual in every household? You’d then should design a posh parser that is aware of which elements of the CSV are referring to parts of a household, and which elements are referring to parts of every individual. One strategy to remedy this drawback is to make use of one other delimiter like “;” to separate every individual’s attribute:


The issue with creating custom-made codecs, nevertheless, is that you simply incur an overhead of sustaining an much more complicated parser.


XML stands for “extensible markup language”. XML was designed in 1996 and formally turned a W3C commonplace in 1998. It was created to raised characterize knowledge codecs with a hierarchical construction. The format appears like this:

<person> <name><br /> Eric<br /> </name><br /> <age><br /> 26<br /> </age> </person> <person> <name><br /> Andrea<br /> </name><br /> <age><br /> 26<br /> </age> </person> <person> <name><br /> Kusco<br /> </name><br /> <age><br /> eight<br /> </age> </person>

Execs – This knowledge format absolutely helps hierarchical knowledge buildings and could be very applicable when receiving complicated knowledge as a response. It’s also very human readable. Most browsers have inbuilt XML readers that can help you examine XML information. Since XML was the primary commonplace hierarchical knowledge format, most APIs have inbuilt performance to routinely convert XML knowledge streams into native knowledge buildings like objects.

Cons – This knowledge format is about 3 times as giant as CSV. It’s because every knowledge component has an related open and shut parameter tag.


JSON stands for (Javascript Object Notation). It was invented in 2001 and have become popularized by Yahoo and Google in 2005 and 2006. It was created as an alternative choice to XML. Like XML, nevertheless, it represents hierarchical knowledge with using commas, curly braces and brackets. An instance of JSON seems to be like this:




Execs – This knowledge format helps hierarchical knowledge whereas being smaller in measurement than XML. As its identify implies, it was additionally created to extra simply parse knowledge into native Javascript objects, making it very helpful for net purposes. JSON is the most effective of each worlds with respect to CSV and XML. It is easy and compact like CSV, however helps hierarchical knowledge like XML. In contrast to XML, JSON codecs are solely about twice as giant as CSV codecs.

Cons – This knowledge format has a bit bit much less help than XML. Since JSON is comparatively newer than XML, fewer APIs exist to routinely convert JSON to native knowledge buildings. Nevertheless, that is quickly altering as a result of newer APIs and plugins are supporting each XML and JSON.


As a basic rule of thumb, JSON is one of the best knowledge change format thus far. It is mild weight, compact, and versatile. CSV ought to solely be used in case you are sending large quantities of knowledge and if bandwidth is a matter. Immediately, XML shouldn’t be used as a knowledge change format as a result of it is higher fitted to doc markups.

Other articles you might like;