Tech

What is TOML?

Published
Published:
Table of Contents

TOML is another config file format. You will meet it in Rust (Cargo.toml) and modern Python (pyproject.toml). The name stands for “Tom’s Obvious Minimal Language”, and “obvious” is exactly the point — it tries to have no surprises.

The whole philosophy

TOML’s goal is that the file means exactly what it looks like it means. Boring, in the best possible way.

How it looks

It feels like the old .ini files, but with proper rules:

title = "My Project"
version = "1.0.0"

[author]
name = "Shravan"
country = "India"

[dependencies]
numpy = "1.26"

Those [author] and [dependencies] lines are called tables. They are just a neat way to group related settings.

Lists and nested tables

languages = ["C++", "Python", "Julia"]

[[servers]]
name = "alpha"
ip = "10.0.0.1"

[[servers]]
name = "beta"
ip = "10.0.0.2"

The double brackets [[servers]] mean “a list of tables” — handy when you have many similar blocks.

The same data, two ways

TOML and JSON describe the same thing; one is tuned for humans editing a file, the other for machines:

Why some people prefer it over YAML

TOML's pitch

Indentation doesn’t matter, so there is no tab-versus-space drama. Types are explicit — strings are quoted, numbers are not. It is hard to write something that means a different thing than you expected.

The trade-off

For deeply nested data it gets a little clumsy and repetitive. When the structure is a deep tree, YAML or JSON read better.

A young format

TOML is recent — created by Tom Preston-Werner (a GitHub co-founder) in 2013, with the stable 1.0.0 spec only arriving in 2021. That is partly why it feels so tidy.

When to use it

Great for project and tool configuration where the settings are mostly flat. If you have ever fought with YAML indentation at 2 AM, TOML will feel like a calm friend.

Support this post Sponsor