$devtoolkit.sh/glossary/what-is-toml

What is TOML? — Tom's Obvious Minimal Language Explained

Definition

TOML (Tom's Obvious Minimal Language) is a minimal configuration file format designed to be easy to read due to obvious semantics. It maps unambiguously to a hash table (dictionary). Unlike YAML, TOML avoids indentation-based structure and has explicit type syntax, making it less error-prone for configuration files. It is the standard format for Rust's Cargo.toml package manifest, Python's pyproject.toml, and many other project configuration files.

How It Works

TOML organizes data into key-value pairs. Keys are written as bare words or quoted strings; values can be strings, integers, floats, booleans, dates, arrays, or inline tables. Sections (tables) are defined with [section] headers, and nested sections use [section.subsection]. Arrays of tables are written as [[array]]. All types are explicit: strings must be quoted, dates follow ISO 8601, and arrays are homogeneous. This explicitness prevents the ambiguity issues that YAML has with strings that look like booleans or numbers.

Common Use Cases

  • Defining Rust package dependencies and metadata in Cargo.toml
  • Configuring Python projects and build tools in pyproject.toml
  • Writing Hugo static site configuration files
  • Configuring Rust-based tools like the Starship shell prompt
  • Any configuration file where unambiguous typing is important

Example

[package]
name = "my-app"
version = "1.0.0"
edition = "2021"

[dependencies]
serde = { version = "1", features = ["derive"] }
tokio = "1"

[server]
host = "127.0.0.1"
port = 8080
tls = false

Related Tools

FAQ

When should I use TOML instead of YAML?
Use TOML when you want unambiguous types, no indentation sensitivity, and clear semantics. TOML is excellent for project manifests (Cargo.toml, pyproject.toml). Use YAML when tooling requires it (Kubernetes, GitHub Actions) or when you need anchors and references.
What are the differences between TOML sections and YAML mappings?
TOML sections ([table]) are equivalent to YAML mappings but defined with bracket headers rather than indentation. TOML is more explicit — there is only one way to express most structures, while YAML has many equivalent syntaxes for the same data.
Can TOML represent all the same data as JSON?
TOML can represent all JSON data types except null (TOML has no null value). TOML also adds native support for date and time types that JSON lacks. For null values in TOML, you typically use an empty string or a custom sentinel value.

Related Terms

/glossary/what-is-tomlv1.0.0