My project lead considers both of these approaches to be unnecessary overhead. I have been involved in and have witnessed a lot of talk around XML vs JSON, but this is the first time that I have heard an argument against BOTH.

We are using c# in .Net 4. We'll be storing data in a sql server database on the server and also on mobile devices. I've heard all the arguments between the two but now I need to understand the arguments for and against the use of any object notation to store data - my project lead prefers csv format.

  • 2
    Well, depends totally on the constraints of your project. Actually XML may add so much overhead that the tags take more size than the data itself, similar for JSON. So if size is an issue you PL may have a point. Processing those formats is only easy if there are good libraries for your tool chain, so again this may or may not be a reason. If you just want to drop some data agains a server then simple CSV may have it's place. Without more details this may become difficult to answer. Commented Aug 30, 2013 at 11:43
  • 1
    Mr.Withersea, your question is too vague and as such, would tend to elicit opinions instead of objective answers. Commented Aug 30, 2013 at 11:43
  • 1
    Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer. Also see How to Ask
    – gnat
    Commented Aug 30, 2013 at 11:45
  • 4
    I don't think this question is answerable without some description of the data. CSV may well make sense for certain sorts of data. (Tabular data, for instance.)
    – user53141
    Commented Aug 30, 2013 at 15:46
  • "my project lead prefers csv format". Ask him how he would transfer tree of complex objects, lists, and more.
    – Euphoric
    Commented Aug 30, 2013 at 20:24

3 Answers 3


There are many libraries that will help you serializing and deserializing your data in XML or JSON. CSV is not so popular anymore, so you may need to do everything yourself. On top of that, both XML and JSON are probably easier to read for a human, which makes debugging easier and faster (i.e. cheaper).

CSV, on the other hand, has less characters for the same data so it takes less disk space and/or bandwidth.

Usually developer time (i.e. costs) is a much bigger constraint than disk space or bandwidth use, so most people will use XML or JSON. Using one or the other is a matter of which libraries you are most familiar with or even cultural reasons (Java and Scala people tend to use XML, Javascript people tend to use JSON). XML is more verbose (i.e. more disk, more bandwidth), but not to the point of being a problem in most modern projects.

If your boss is quite old, maybe he remembers the days when it made a difference to send data over the wire in a plain compact format (like CSV, or even an ad-hoc binary format) instead of XML, but that is very rarely an issue with modern computers and modern networks.

  • Look for a CSV parser before you write one, though. Python's CSV parser is quite good. Of the three, I personally find JSON the most human readable and is more natural for data that that comes in key/value pairs. Whether XML is readable depends a lot on how it is used.
    – user53141
    Commented Aug 30, 2013 at 17:05
  • "Whether XML is readable depends a lot on how it is used." True. Some abused XMLs out there are not really readable.
    – sergut
    Commented Aug 30, 2013 at 17:26

It's all about the trade off between the size of transmitted data (and hence the time taken to transmit it) and the ease of converting it to / from your class objects.

A hand crafted binary format will have a smaller size then JSON or XML, but will that require much more effort to code and test routines for serialisation / de-serialisation.

Just about every programming language / platform has mature and well tested libraries for XML and JSON that you can plug in with minimal effort.

  • The question is about XML or JSON vs CSV, not binary.
    – 17 of 26
    Commented Aug 30, 2013 at 14:38
  • 2
    It wasn't when I answered
    – Peregrine
    Commented Aug 30, 2013 at 14:48

The benefits of binary: smaller size, and faster (de)serialisation. The small size can also mean faster transmission, especially if you're using a slow network (eg mobile).

Sure, the programmer might have more work to do but that depends on the library used to perform the serialisation. If you're using a JSON or XML library to do this, I would expect that you could replace the internals of that library with a binary protocol and not even notice the change. (in fact, I know this - we did it once, our serialisation lib was XML, when we replaced the object with a binary version, overall performance of our program increased by 20%).

I would expect that the only true benefit of JSON or XML is that a human can read the data whilst it is serialised. Whether this really is useful depends if you're using the data for storage or just for communication. Even then, create a tool to show you the contents.

Incidentally, csv format is still just as bad - the split is fundamentally between some form of textual format, or a binary one. Given the choice between csv, xml or json ... I would have to say "what's the data stored", csv can be a very good choice for a lot of data, especially as you already have a tool to manipulate it (a spreadsheet) or to import it into a database. If the data is hierarchical in some way (eg a graph or tree) then csv isn't such a good choice.

  • 3
    The trouble with binary formats is the complete lack of portability. They also tend to be far less flexible.
    – user53141
    Commented Aug 30, 2013 at 15:44
  • 1
    @StevenBurnap - binary formats can be portable. ASN.1 BER is used all over the world, among others. Commented Aug 30, 2013 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.