TOML Syntax Reference

TOML v1.0 tables, arrays, inline tables, dates and value types explained.

Searchable TOML v1.0.0 syntax reference covering bare and quoted keys, dotted keys, tables, arrays of tables, every string variant, number formats and the four RFC 3339 date-time types. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What is an array of tables in TOML?

Double square brackets like [[products]] append a new table to an array each time they appear. Repeating the header three times builds an array of three table objects, which is how TOML expresses a list of structured records.

A tour of TOML v1.0.0 syntax

TOML (Tom’s Obvious, Minimal Language) is a configuration format designed to be easy to read and to map cleanly onto a hash table. It powers Cargo.toml, pyproject.toml and many other tool configs. This reference covers keys and tables, every string variant, number formats, arrays and the four date-time types.

How it works

A TOML file is a set of key/value pairs grouped into tables. A header in square brackets opens a table; dotted names create nesting; double brackets build an array of tables:

title = "Example"

[server]
host = "127.0.0.1"
ports = [80, 443]
tls = { enabled = true, min = "1.2" }

[[products]]
name = "A"
[[products]]
name = "B"

created = 1979-05-27T07:32:00Z

Every value has a clear type: integers (with _ separators and 0x/0o/0b prefixes), floats, booleans (true/false only), strings in four flavours, arrays, and the RFC 3339 temporal types. Files must be valid UTF-8.

The four string types

TOML’s string system is the part developers most often get wrong. Choosing correctly avoids tedious escaping:

TypeSyntaxEscapingWhen to use
Basic"hello\nworld"Backslash sequencesDefault; supports \n, \t, \\, \", and Unicode escapes
Multiline basic"""...."""Same as basicLong strings that need line breaks in the source file
Literal'C:\Users\name'NoneWindows paths, regex, anything where backslashes should be literal
Multiline literal'''...'''NoneLong literal blocks; first newline after ''' is stripped

The most common mistake: putting a Windows path in a basic string and forgetting to escape the backslashes. Use a literal string (single quotes) and the path is copied verbatim.

Tables versus arrays of tables

Single brackets [section] open a named table. You cannot redefine it later — attempting to creates a parse error. Double brackets [[section]] append a new element to an array of tables every time they appear. This is TOML’s equivalent of a list of objects:

[[dependencies]]
name = "tokio"
version = "1"

[[dependencies]]
name = "serde"
version = "1"

This produces an array of two table objects, exactly how Cargo.toml represents your package’s dependency list.

Date-time types

TOML has four temporal types that map to common calendar objects without requiring string parsing:

  • 1979-05-27T07:32:00Z — offset date-time (with timezone)
  • 1979-05-27T07:32:00 — local date-time (no timezone)
  • 1979-05-27 — local date
  • 07:32:00 — local time

These are written without quotes. Parsers expose them as native date/time objects, which avoids the fragile custom string parsing that plagues formats like JSON.

Common pitfalls

  • Redefining a key is a hard error, not a silent override. This is intentional and prevents the class of bugs where a config file has two contradictory values for the same key and you have to guess which wins.
  • Booleans are lowercase only. true and false work; True, False, YES, and yes are parse errors.
  • Inline tables must be complete on one line and cannot be extended later with dotted keys.

Tips and notes

  • Use literal strings (single quotes) for Windows paths and regex to avoid escaping.
  • [[name]] appends to an array of tables; plain [name] defines a single table.
  • Booleans are lowercase only; there is no True or yes.
  • Defining the same key twice is an error — that strictness prevents silent overrides.
  • In pyproject.toml, the [tool.X] pattern uses dotted table headers to namespace each tool’s configuration within the same file.