GeekBits

TOML Cheat Sheet

A quick reference material for TOML configuration language.

1 min read
TOML Cheat Sheet

TOML (Tom's Obvious, Minimal Language) is a minimal configuration file format that's easy to read because of its simple semantics. It's used in various applications such as Rust configuration files. It facilitates data interchange between languages with different data types, and more making it a very choice for configuration files.

Comments

# This is a comment in TOML.

Basic Data Types

# Strings
string = "Hello, World!"

# Integers
integer = 42

# Floats
float = 3.14

# Booleans
bool = true

DateTime

# Date and time (RFC 3339)
datetime = 2023-06-19T12:30:00Z

# Date
date = 2023-06-19

# Time
time = 12:30:00

Arrays

# An array of integers
integers = [1, 2, 3]

# An array of strings
strings = ["hello", "world"]

# Arrays can contain different types.
mixed = [1, "two", 3.14]

# You can even have nested arrays.
nested = [[1, 2], [3, 4, 5]]

Tables (equivalent to dictionaries or objects)

# A table
[table]
key = "value"

# Nested tables
[table.subtable]
key = "another value"

# Inline tables
name = { first = "Tom", last = "Preston-Werner" }

Arrays of Tables

[[products]]
name = "Hammer"
sku = 738594937

[[products]]
name = "Nail"
sku = 284758393

Keys

# Normal key
key = "value"

# Key with special characters
"127.0.0.1" = "localhost"

# Dotted key (creates a table)
animal.type = "cat"

# Multi-line strings
string2 = """
Hello,
World!
"""

Misc

# You can use scientific notation and underscores in numbers.
number = 1e6
number_with_underscore = 1_000

# Boolean values are lower-case.
bool = true
bool = false

Downloadable Copy

Grab a downloadable copy of the cheat sheet using the link provided below.

Conclusion

A very fundamental cheat sheet for the most common TOML features and syntax.

Sign up for our newsletter

Don't miss anything. Get all the latest posts delivered to your inbox. No spam!