TOML Syntax Cheat Sheet
Key-value pairs, tables, arrays, and data types for writing valid TOML configuration files like pyproject.toml and Cargo.toml.
1 PageBeginnerFeb 15, 2026
Key-Value Pairs & Basic Types
The core scalar types TOML supports.
toml
title = "My App"version = "1.4.0"port = 8080debug = falsepi = 3.14159created = 2026-03-12T10:00:00Z # RFC 3339 datetime, no quotestags = ["cli", "rust", "tool"] # arrayowners = ["alice", "bob"]
Tables & Nested Tables
Tables group related keys, like a JSON object under a name.
toml
[package]name = "my-app"version = "1.4.0"edition = "2021"[package.metadata.docs]all-features = true[dependencies]serde = { version = "1.0", features = ["derive"] } # inline tabletokio = "1.38"
Array of Tables
Repeated `[[section]]` blocks produce an array of tables under that key.
toml
[[bin]]name = "cli"path = "src/main.rs"[[bin]]name = "worker"path = "src/worker.rs"# Equivalent JSON: { "bin": [ {"name":"cli",...}, {"name":"worker",...} ] }
Type Reference
The data types TOML natively supports and how they're written.
- String- basic "double-quoted" (escapes) or 'single-quoted' (literal)
- Multi-line string- triple-quoted """...""", first newline after opener is trimmed
- Integer- 42, -17, 1_000_000 (underscores allowed as separators)
- Float- 3.14, 1e10, inf, nan
- Boolean- true / false, lowercase only
- Datetime- RFC 3339: offset, local datetime, local date, or local time
- Array- [1, 2, 3], can be multi-line, trailing comma allowed
Pro Tip
Prefer dotted keys (`server.host = "localhost"`) over deeply nested `[server]` tables when you only have one or two fields — it keeps short configs like `pyproject.toml` snippets readable without an extra table header.
Was this cheat sheet helpful?
Explore Topics
#TOMLSyntax#TOMLSyntaxCheatSheet#ToolsOthers#Beginner#KeyValuePairsBasicTypes#TablesNestedTables#ArrayOfTables#TypeReference#DataStructures#CheatSheet#SkillVeris