Development

TOML Cheat Sheet

Captain Salem 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

Conclusion

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

Share
Comments
More from Cloudenv

Cloudenv

Developer Tips, Tricks and Tutorials.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Cloudenv.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.