📖 Guide
TOML — Complete Reference
Quick reference for TOML configuration file syntax, types, tables, and common patterns.
61 commands across 10 categories
Basic Types
| Command | Description |
|---|---|
key = "value" | String value |
key = 42 | Integer value |
key = 3.14 | Float value |
key = true | Boolean value (true or false) |
key = 1979-05-27T07:32:00Z | Offset date-time (RFC 3339) |
key = [1, 2, 3] | Array value |
bare_key = "value" | Bare keys: letters, digits, dashes, underscores |
"spaced key" = "value" | Quoted keys for special characters |
Strings
| Command | Description |
|---|---|
str = "hello\nworld" | Basic string with escape sequences |
str = 'C:\Users\path' | Literal string (no escaping, single quotes) |
str = """multi
line""" | Multi-line basic string (triple double quotes) |
str = '''multi
line''' | Multi-line literal string (triple single quotes) |
"\u0041"e.g. \u0041 = A | Unicode escape (4-digit) |
"\U00010437" | Unicode escape (8-digit) |
"""line \
continuation""" | Line-ending backslash trims newline and whitespace |
Numbers
| Command | Description |
|---|---|
int = 42 | Basic integer |
int = 1_000_000 | Integer with underscores for readability |
hex = 0xDEADBEEF | Hexadecimal integer |
oct = 0o755 | Octal integer |
bin = 0b11010110 | Binary integer |
flt = 3.14 | Float value |
flt = 5e+22 | Float with exponent |
special = inf | Infinity (also nan, +inf, -inf) |
Dates
| Command | Description |
|---|---|
odt = 1979-05-27T07:32:00Z | Offset date-time (UTC) |
odt = 1979-05-27T07:32:00+02:00 | Offset date-time with timezone |
ldt = 1979-05-27T07:32:00 | Local date-time (no timezone) |
ld = 1979-05-27 | Local date |
lt = 07:32:00 | Local time |
odt = 1979-05-27 07:32:00Z | Space instead of T delimiter (allowed) |
Arrays
| Command | Description |
|---|---|
arr = [1, 2, 3] | Basic array |
arr = ["a", "b", "c"] | String array |
arr = [
1,
2,
] | Multi-line array (trailing comma OK) |
mixed = [[1, 2], ["a", "b"]] | Nested arrays |
arr = [1, "two", 3.0] | Mixed-type array (TOML v1.0+) |
Tables
| Command | Description |
|---|---|
[table]e.g. [server]
host = "localhost"
port = 8080 | Define a table (object/section) |
[parent.child] | Dotted table (nested object) |
a.b = "value" | Dotted key (inline nesting) |
[a]
[a.b] | Sub-table defined separately |
[tool.poetry]e.g. [tool.poetry]
name = "myproject"
version = "1.0" | Common pattern: namespaced config |
[servers.alpha]
ip = "10.0.0.1" | Multiple named sub-tables |
Inline Tables
| Command | Description |
|---|---|
point = {x = 1, y = 2} | Inline table (single line) |
name = {first = "Tom", last = "Riddle"} | Inline table with strings |
animal = {type.name = "pug"} | Dotted keys inside inline table |
{} | Empty inline table |
config = {debug = true, level = "info"} | Compact configuration object |
Array of Tables
| Command | Description |
|---|---|
[[products]]e.g. [[products]]
name = "Hammer"
sku = 738594937 | Array of tables — each creates a new entry |
[[products]]
name = "Nail" | Second entry in the same array |
[[fruits]]
[[fruits.varieties]] | Nested array of tables |
[[tool.poetry.dependencies]] | Dotted array of tables |
[[servers]]
role = "frontend" | Common pattern: server list |
Common Patterns
| Command | Description |
|---|---|
[package]
name = "app"
version = "1.0.0" | Cargo.toml / pyproject.toml package section |
[dependencies]
serde = "1.0" | Dependency listing (Rust Cargo) |
[tool.ruff]
line-length = 88 | Python tool config in pyproject.toml |
edition = "2021" | Simple key-value configuration |
[profile.release]
opt-level = 3 | Build profile configuration |
[env]
DATABASE_URL = "postgres://..." | Environment variable configuration |
📖 Free, searchable command reference. Bookmark this page for quick access.
Comments
# This is a commentkey = "value" # inline comment# No block comments in TOML# key = "disabled"# [section] # key = "val"