In this article
What Is TOML?
TOML (Tom's Obvious, Minimal Language) is a configuration file format designed to be easy to read and write. Created by Tom Preston-Werner (co-founder of GitHub), TOML maps clearly to a hash table and is intended to be unambiguous — every TOML document has exactly one valid interpretation.
TOML is the configuration format of choice for Rust (Cargo.toml), Python (pyproject.toml), and many static site generators. It supports comments, date-time literals, and nested tables while remaining simpler than YAML and more human-friendly than JSON.
TOML Syntax Rules
TOML syntax is designed to be minimal and unambiguous. Here are the core elements of the language.
- Key/value pairs — the basic building block, written as key = value on each line. Keys can be bare (unquoted), quoted, or dotted for nested access.
- Tables — sections defined with [table_name] headers that group related key/value pairs. Tables can be nested using dotted keys or [[array_of_tables]] syntax.
- Arrays — ordered lists defined with square brackets [1, 2, 3]. All elements must be of the same type. Multi-line arrays are allowed with trailing commas.
- Date-time literals — TOML natively supports RFC 3339 dates like 2026-03-15T14:30:00Z, local dates (2026-03-15), local times (14:30:00), and date-time offsets.
- Multiline strings — triple-quoted strings ("""text""") preserve line breaks and allow long content without escape sequences. Literal strings use single quotes ('no\escape').
Common TOML Patterns
TOML is widely used in project configuration files across different ecosystems.
- Cargo.toml — Rust's package manager uses TOML for project metadata, dependencies, build profiles, and workspace configuration
- pyproject.toml — Python's modern build system configuration, defined by PEP 517/518, replaces setup.py and setup.cfg with a standardized TOML file
- Hugo config — the Hugo static site generator uses TOML (or YAML/JSON) for site configuration including themes, menus, taxonomies, and build settings
- Netlify config — netlify.toml configures build commands, redirect rules, environment variables, and deploy contexts for Netlify sites
Try it free — no signup required
Validate TOML Online →Common Validation Errors
TOML is strict by design — many errors that YAML would silently accept will fail in TOML. Here are the most common validation issues.
- Duplicate keys — TOML forbids defining the same key twice in the same table. This includes keys set via dotted notation and regular table headers.
- Invalid date format — TOML requires RFC 3339 dates. Common mistakes include missing the T separator (2026-03-15 14:30:00 instead of 2026-03-15T14:30:00), or using slashes instead of hyphens.
- Mixed array types — all elements in a TOML array must be the same type. [1, "two", 3] is invalid because it mixes integers and strings.
- Unclosed strings — forgetting to close a quoted string or using the wrong quote type causes parse errors. Watch for mismatched triple quotes in multiline strings.
TOML vs YAML vs JSON
Each format has strengths that make it better suited for certain use cases.
- Readability — TOML and YAML are both highly readable for humans. TOML uses explicit syntax (brackets, equals signs) while YAML relies on indentation. JSON is less readable for configuration due to required quotes and no comments.
- Strictness — TOML is the strictest of the three. It rejects ambiguous constructs and has no implicit type coercion. YAML's flexibility (yes/no as booleans, bare strings) often causes unexpected behavior.
- Comments — both TOML and YAML support comments (TOML uses #, YAML uses #). JSON has no comment support at all, which makes it less suitable for configuration files that need documentation.
Frequently Asked Questions
How do nested tables work in TOML?
TOML supports nested tables through two mechanisms: dotted keys (a.b.c = value) and table headers ([parent.child]). Both create the same nested structure. For arrays of tables (like multiple package dependencies), use double brackets ([[array_name]]). Each [[array_name]] block adds a new element to the array.
What are the differences between TOML v1.0 and earlier versions?
TOML v1.0 (released in January 2021) is the first stable release. Key changes from pre-1.0 drafts include clarified datetime handling, formalized inline table semantics, and refined array of tables behavior. Most modern tools use TOML v1.0 — if you are writing new configuration files, target v1.0.
How do I convert YAML to TOML?
YAML and TOML have different data models, so conversion is not always one-to-one. Simple key-value structures and nested objects convert directly. YAML features like anchors, aliases, and complex keys have no TOML equivalent. For most configuration files, conversion is straightforward — map YAML dictionaries to TOML tables and YAML lists to TOML arrays.