TOML

2023-10-05

YAML, JSON, INI, and TOML are popular choices for configuration files, and they are replacing XML for good. While the first three are familiar and straightforward, TOML (Tom's Obvious Minimal Language) is an interesting choice. Let's take a closer look.

The official description of TOML says:

"TOML aims to be a simple configuration file format that's easy to read because it has clear rules. TOML is designed to easily turn into a data structure, like a table or a dictionary, in many programming languages. TOML should be easy to change into data structures in many different programming languages."

TOML lets you create objects, which are called tables here, using a simple syntax that avoids the need for nesting objects. For example:

[parent-object]
field1 = "the value"

[parent-object.child-object]
field2 = "another value"

The same goes for arrays of objects:

[[user]]
id = "1"
name = "user1"

[[user]]
id = "2"
name = "user2"

Another interesting feature is its support for date and time:

ldt1 = 1979-05-27T07:32:00 
ldt2 = 1979-05-27T00:32:00.999999

In terms of file size, TOML generally falls between JSON and YAML.

Subscribe for daily updates on software development, productivity, and more.