TOML Cheatsheet - TOML Configuration Reference

Tools like Cargo, Hugo and Greenlet configure with TOML, whose explicit [table] blocks and key = value syntax make it more readable than JSON and support comments. This reference groups 6 sections: basic types, date-time, four string flavors, arrays and tables, arrays of tables, plus a ready-to-adapt Cargo.toml example. Mirror the structure while writing a dependency table or nested section, and look up string escaping or date-time offsets as needed to avoid common type and indentation ambiguity. After reading you can maintain Cargo.toml and similar TOML config on your own.

Config Formats·38 commands·Last updated 2026-07-21
tomlConfig Files

Basic Types 11

# this is a comment
Comment (# to end of line)
key = "value"
String
key = 'value'
Literal string (no escapes)
int = 42
Integer
hex = 0xFF
Hex integer
oct = 0o17
Octal integer
bin = 0b101
Binary integer
num = 1_000_000
Underscore separators (readability)
float = 3.14
Float
flt = inf
Special float (inf / -inf / nan)
bool = true
Boolean

Date & Time 5

date = 2026-07-19
Local date
time = 14:30:00
Local time
datetime = 2026-07-19T14:30:00
Local datetime (no timezone)
datetime = 2026-07-19T14:30:00Z
UTC datetime
datetime = 2026-07-19T14:30:00+08:00
Offset datetime

Strings 4

str = "Hello\nWorld"
Basic string (escapes supported)
str = """Hello\nWorld"""
Multiline basic string
str = 'C:\\path\\to\'
Literal string (no escapes)
str = '''C:\\path\\to\'''
Multiline literal string

Arrays & Tables 6

array = [1, 2, 3]
Array
array = [\n 1,\n 2,\n 3,\n]
Array may span lines (trailing comma optional)
[table]
Table (section)
[table.subtable]
Subtable (dotted table name)
physical.color = "orange"
Dotted keys (equivalent to subtable)
inline = { key1 = "value1", key2 = 2 }
Inline table

Array of Tables 4

[[products]]
Array of tables (first element)
name = "Apple"
Array-of-tables field
[[products]]
Array of tables (second element)
name = "Banana"
Array-of-tables field

Cargo.toml Example 8

[package]
Package info
name = "myapp"
Package name
version = "0.1.0"
Version
edition = "2021"
Rust edition
[dependencies]
Dependencies
serde = "1.0"
Dependency version
serde = { version = "1.0", features = ["derive"] }
Dependency with features
[dev-dependencies]
Dev dependencies

Tips

  • TOML prioritizes readability and fits config files better than JSON.
  • Strings come in basic (double-quoted, escapes) and literal (single-quoted, no escapes).
  • Tables [table] and arrays of tables [[array]] are TOML's core structures.

Official References

Each command links to its official documentation below, so you can verify the latest usage and read deeper.

Maintained by LaoHand

Publicly updated on Jul 21, 2026, continuously proofread against official docs.

Contact Us

Wrong command or description? Send us corrections, business inquiries or product feedback by email.

Contact Us