Vasanth Developer
7 Alternatives To JSON

7 Alternatives To JSON

4 min readJun 28, 2022On Dev

JavaScript Object Notation (JSON) is the most popular data serialization format these days 🙌

It is used in RESTful APIs, configuration files, for storing complex data in stringular format and much more. It's ability to be minified/compressed and human readability is what made it so popular.

JSON was initially specified in early 2000 and the first messages in JSON format were written in April of 2001. It has been accepted as an international standard in 2013.

JSON
{
	"name": "Vasanth Srivatsa",
    "twitter": "vsnthdev",
    "stack": ["JavaScript", "TypeScript", "Docker"],
    "portfolio": {
    	"link": "https://vsnth.dev"
	}
}

1️⃣ JSON5 Data Interchange Format

JSON5 is a superset on top of JSON that adds additional functionality to the JSON spec. Double-quotes are not enforced and single-quotes can also be used to represent strings. Trailing commas are also possible, creating a more human readable version of JSON 👌

Although it definitely is a better implementation of JSON, support for JSON5 hasn't been implemented and hardened in a lot of programming languages yet except for JavaScript/TypeScript.

JSON5
{
	name: 'Vasanth Srivatsa',
    twitter: 'vsnthdev',
    stack: ['JavaScript', 'TypeScript', 'Docker'],
    portfolio: {
    	link: 'https://vsnth.dev'
    }
}

2️⃣ Binary JSON (BSON)

If human-readability isn't required, BSON offers ⚡ faster serialization (parsing) and deserializing (stringifying). BSON was created in 2009 to be used within MongoDB database.

It supports storing more data types than what JSON offers by default. But just like JSON5 support is lacking.

3️⃣ Yet Another Markup Language (YAML)

YAML is my favorite ✨ as it offers most readability with wide support and hardened libraries in different programming languages.

For user-interacting files containing small-to-medium amount of data like configuration files, YAML is perfect 👌 but JSON is faster when compared with YAML.

YAML
name: 'Vasanth Srivatsa'
twitter: 'vsnthdev'
stack:
	- JavaScript
    - TypeScript
    - Docker
portfolio:
	link: https://vsnth.dev

4️⃣ Tom's Obvious Markup Language (TOML)

Bringing a little more power while keeping focus on human-readability is TOML. Large & complex user-interactive data files, like config files of a large application are a perfect use-case for TOML.

Though it is slower compared to YAML & JSON & has slightly less support than YAML, TOML has 💪 powerful features like dot notation and support for more data types.

TOML
name = "Vasanth Srivatsa"
twitter = "vsnthdev"
stack = [ "JavaScript", "TypeScript", "Docker" ]
 
[portfolio]
link = "https://vsnth.dev"

5️⃣ CoffeeScript Object Notation (CSON)

Mainly popularized by the Atom code editor, CSON is visually similar to YAML. Only difference between JSON and CSON is that curly brackets {} and square brackets [] are omitted in place of indentation.

With Atom editor coming close to end of life 😔 support for CSON is limited & uncertain. It also has very limited support outside of the JavaScript ecosystem.

CSON
name: 'Vasanth Srivatsa'
twitter: 'vsnthdev'
stack: [
	'JavaScript',
    'TypeScript',
    'Docker'
]
portfolio:
	link: 'https://vsnth.dev'

6️⃣ Comma Seperated Values (CSV)

Out of all the above discussed data serialization formats, CSV is the most compact 🤏 and smallest. CSV format is more suited for long and tabular data than config files.

CSV parsers are available widely for almost all programming languages, with support for customization of the spec.

CSV
"name", "twitter", "stack", "portfolio__link"
"Vasanth Srivatsa", "vsnthdev", "JavaScript", "https://vsnth.dev"
"", "", "TypeScript", ""
"", "", "Docker", ""

7️⃣ Extensible Markup Language (XML)

Introduced by W3C and published in 1998, it is the oldest data serialization format in this list. Although it is powerful, it contains a lot of boilerplate code with repetitive tags wrapping each value 👎

It has wide support and has libraries in almost all programming languages.

XML
<?xml version="1.0" encoding="UTF-8" ?>
<root>
    <name>Vasanth Srivatsa</name>
    <twitter>vsnthdev</twitter>
    <stack>JavaScript</stack>
    <stack>TypeScript</stack>
    <stack>Docker</stack>
    <portfolio>
        <link>https://vsnth.dev</link>
    </portfolio>
</root>

Conclusion

All of the 👆 above discussed data serialization formats have their pros & cons. These are the most popular formats, other notable mentions include ProtoBuf, MessagePack, Avro, Parquet and many more.

Thank you 😊

Share this page