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

Whether you’re construction a skinny Jstomer (internet utility) or thick Jstomer (client-server utility) in the future you’re most definitely making requests to a internet server and desire a excellent information structure for responses. As of nowadays, there are 3 main information codecs getting used to transmit information from a internet server to a shopper: CSV, XML, and JSON. In order to broaden an utility with a forged structure, it is a good suggestion to grasp the variations between every structure and know when to make use of them. The function of this submit is to outline every information structure, lay out the professionals and cons for every, and uncover which eventualities paintings absolute best with every structure.


CSV stands for “comma separated values”. As the title implies, this knowledge structure is principally a listing of parts separated by means of commas. Let’s say that your reaction is sending again a listing of folks in a specific circle of relatives. The structure would appear to be this:


Pros – This structure is essentially the most compact of all 3 codecs. Generally talking, CSV codecs are about part the dimensions of XML and JSON codecs. This is the main good thing about CSV as a result of it could possibly lend a hand cut back bandwidth

Cons – This structure is the least flexible of all 3 codecs. This is as a result of a selfmade parser is needed to transform the CSV information right into a local information construction. As a consequence, if the information construction adjustments, there’s an related overhead of getting to modify and even redesign your parsers. Furthermore, because the program growing the CSV and this system parsing the CSV live on other machines (keep in mind that we’re passing information from one device to any other) then each methods should be up to date concurrently to forestall the receiving program to crash. Otherwise, an outage is needed to replace each methods in my view to forestall incompatibility problems.

Finally, CSV does now not in reality fortify information hierarchies. What when you sought after to ship again attributes for every particular person in every circle of relatives? You would then must design a posh parser that is aware of which portions of the CSV are relating to parts of a circle of relatives, and which portions are relating to parts of every particular person. One approach to clear up this downside is to make use of any other delimiter like “;” to split every particular person’s characteristic:


The downside with growing custom designed codecs, alternatively, is that you just incur an overhead of keeping up an much more complicated parser.


XML stands for “extensible markup language”. XML used to be designed in 1996 and formally was a W3C usual in 1998. It used to be created to raised constitute information codecs with a hierarchical construction. The structure seems 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 /> 8<br /> </age> </person>

Pros – This information structure absolutely helps hierarchical information constructions and may be very suitable when receiving complicated information as a reaction. It may be very human readable. Most browsers have inbuilt XML readers that assist you to investigate cross-check XML information. Since XML used to be the primary usual hierarchical information structure, maximum APIs have inbuilt capability to robotically convert XML information streams into local information constructions like items.

Cons – This information structure is ready thrice as massive as CSV. This is as a result of every information part has an related open and shut parameter tag.


JSON stands for (Javascript Object Notation). It used to be invented in 2001 and was popularized by means of Yahoo and Google in 2005 and 2006. It used to be created as a substitute for XML. Like XML, alternatively, it represents hierarchical information with using commas, curly braces and brackets. An instance of JSON seems like this:




Pros – This information structure helps hierarchical information whilst being smaller in measurement than XML. As its title implies, it used to be additionally created to extra simply parse information into local Javascript items, making it very helpful for internet programs. JSON is the most efficient of each worlds with admire to CSV and XML. It’s easy and compact like CSV, however helps hierarchical information like XML. Unlike XML, JSON codecs are best about two times as massive as CSV codecs.

Cons – This information structure has just a little bit much less fortify than XML. Since JSON is quite more recent than XML, fewer APIs exist to robotically convert JSON to local information constructions. However, that is abruptly converting as a result of more recent APIs and plugins are supporting each XML and JSON.


As a basic rule of thumb, JSON is the most efficient information change structure to this point. It’s gentle weight, compact, and flexible. CSV must best be used in case you are sending large quantities of information and if bandwidth is a matter. Today, XML must now not be used as a knowledge change structure as a result of it is higher fitted to file markups.

Tags :