What you need to know about JSON vs XML vs Protobuf

What you need to know about JSON vs XML vs Protobuf

Any application needs to access data from somewhere. Whether it’s a local db, remote db, or even a text file you probably have persisted data somewhere and how your application receives that data can differ drastically.


While its looking like JSON is the winner in 2020, it’s important to know how we got here and what important lessons we can learn from that past, this article will explore briefly the history and differences between 2 of the most popular data formats this century (so far) and how they differ.

What is JSON?

Short for “JavaScript Object Notation” this format has low overhead, easily readable, and supported by JavaScript by default.

You can read the whole JSON spec here but in short JSON is a array of objects or a single object where there are a set of key/value pairs which can include numbers, strings, objects, or arrays of numbers/strings/objects. For example:

// Top level array with nested objects
    {"name":"Nick", "email":"hi@imnick.dev"},  

// Top level object with a string value and number value
    “name”: “Brad Pitt”,
    “age”: 43

What is XML?

Short for “extensible markup language” this format is customizable, historically great development tools, one less letter to type.

You can read the whole XML spec here. XML is a collection of tags similar to HTML but rather then tags like div, paragraph, img, etc the tags map to data types that can be highly customized to the requirements of the application.

<?xml version="1.0" ?>
    <Name> Brad Pitt </Name>
    <Age> 43 </Age>

History of the formats

I would recommend checking out this article by TwoBitHistory but the quick version is XML was extremely popular throughout the late 90’s and 2000’s. JSON was created in 2001 but because of heavy investment in XML from companies like Microsoft it will be nearly a decade before we really see popularity begin to shift toward it.


Why is JSON so successful?

I’ve worked professionally with both XML and JSON and I haven’t met people that really liked XML. I didn’t leave my previous job that used XML solely because it used XML but it certainly was a contributing factor, in a world where developers are in short supply it’s important to keep them happy at work and the tech stack you use is a huge part of that.

Will this trend continue?

Ive spoken to many junior developers that have never used XML so if your a company that’s trying to aggressively hire it adds one more thing that needs to be learned when you onboard somebody. I’m not a betting person but with things like GraphQL exploding in popularity over the last several year which uses JSON format I don’t see it going anywhere.

What’s next?


Protocol Buffers (referred to as Protobufs) are Googles alternative to XML/JSON and give up the readability of JSON but are extremely performant. There are several similar technologies from other players like Ion (Amazon), Apache Thrift (Facebook), and Bond (Microsoft) but Protobuf is officially supported by gRPC and looks to be the favorite if you need the highest performance possible. gRPC and protobufs are probably overkill for any client application but can be a game changer for modern micro service architecture where a single client request can create many requests across a number of backend services.

The future of protobufs seems bright and while I think any developer should keep an eye on them, it doesn’t mean JSON is going anywhere soon.

Thank you for the read!

If you want to read more dev tips checkout my blog here!