What is TOML?
TOML (Tom's Obvious Minimal Language) is a minimal configuration file format that is easy to read due to its clear semantics. It is designed to map unambiguously to a hash table and should be easy to parse into data structures in a wide variety of languages.
TOML is widely used in projects like Rust (Cargo.toml), Python (pyproject.toml), Hugo, Deno, Starship prompt, Pipenv (Pipfile), and many application configuration files where clarity and simplicity are valued over flexibility.
TOML Structure
TOML is built on a few core concepts:
- Key/Value Pairs: The basic building block. Keys are on the left of the equals sign, values on the right:
key = "value"
- Tables: Collections of key/value pairs defined by headers in square brackets:
[table]. Dotted keys like [server.database] create nested tables.
- Arrays: Ordered collections in square brackets:
[1, "two", 3.0]. Arrays of tables use double brackets: [[products]]
- Strings: Four types — basic (
"..."), literal ('...'), multi-line basic ("""..."""), and multi-line literal ('''...''').
Unlike YAML, TOML does not rely on indentation for structure. Everything is explicit, making it less error-prone for configuration files.
TOML vs YAML vs JSON
TOML, YAML, and JSON are all popular data serialization formats, each with different strengths:
- TOML vs YAML: TOML uses explicit
= for assignment and [table] headers. YAML uses indentation. TOML is less error-prone because there's no indentation sensitivity. Both support comments.
- TOML vs JSON: TOML supports comments (with
#), has native date/time types, and is more human-readable for config files. JSON is more widely supported and better for data interchange.
- When to use TOML: Configuration files where human readability and unambiguous parsing are priorities. Especially popular in Rust and Python ecosystems.
- When to use YAML: Complex nested data, Kubernetes manifests, CI/CD pipelines. More flexible but more error-prone.
- When to use JSON: API responses, data interchange between services, and when comments are not needed.
TOML Validation Rules
- Keys must be on the left of =:
key = "value" is valid. Bare keys can contain letters, digits, dashes, and underscores.
- Values must have a type: Strings need quotes. Numbers, booleans (
true/false), dates, arrays, and inline tables all have specific syntax.
- No duplicate keys: Within the same table, keys must be unique. Redefining a key is an error.
- No duplicate tables: Each
[table] header can only appear once (except [[array_of_tables]]).
- Strings must be closed: Opening quotes must have matching closing quotes. Multi-line strings use triple quotes.
- Comments use #: Everything after
# on a line is a comment. Comments must be on their own line or after a value.
Using This TOML Validator
This tool helps you validate TOML online quickly and accurately:
- Validate: Checks if your TOML is syntactically correct and shows detailed error information if not.
- Format: Validates and then pretty-prints your TOML with consistent formatting.
- TOML → JSON: Converts your TOML to equivalent JSON format, useful for APIs and debugging.
- Copy: Copies the current output content to your clipboard.
- Clear: Clears the input area to start fresh.
When an error is found, you'll see the exact line and column number, plus a description of what went wrong. This makes debugging malformed TOML much easier than reading raw parser errors.