How to use the toml validator
- Paste or type your TOML document into the text area.
- The toml validator checks the syntax automatically as you type.
- If the document is valid, a success message appears below the input.
- If there is an error, read the reported line number and description to fix it.
- Use TOML Formatter to clean up your document once it passes validation.
What this toml validator checks
This tool implements a parser for the TOML v1.0.0 specification. It validates the structure of your document by checking every syntactic rule defined in the standard. Specifically, it verifies bare keys, quoted keys, dotted keys, basic strings, literal strings, multiline strings, integers (decimal, hexadecimal, octal, binary), floats (including inf and nan), booleans, offset date-times, local dates, local times, arrays, inline tables, standard tables, and arrays of tables.
It also enforces semantic rules that a simple regular expression cannot catch. For example, it ensures that no key is defined more than once within the same scope, and that you do not add sub-keys to a table that was already defined using an array of tables header like [[items]].
Common TOML syntax mistakes
Even experienced developers make small typos when writing configuration files. Here are the most frequent issues caught by a toml validator:
- Missing quotes around strings: TOML requires all string values to be wrapped in single or double quotes. Writing
name = Aliceinstead ofname = "Alice"will fail. - Trailing commas in inline tables: Unlike arrays, inline tables such as
point = {x = 1, y = 2}must not have a comma after the final element. - Duplicate keys: Defining
port = 80twice in the same table is invalid. The second definition will trigger an error. - Unescaped control characters: Basic strings cannot contain raw control characters (U+0000 to U+001F) except for tab. They must be escaped using sequences like
\nor\t. - Incorrect table headers: A table header must be enclosed in square brackets, like
[database]. Missing the closing bracket is a common typo.
TOML data types reference
TOML supports a specific set of data types. Understanding them helps you write valid configuration files on the first try.
| Type | Example | Notes |
|---|---|---|
| String | "hello", 'world' | Basic strings allow escapes; literal strings do not. |
| Integer | 42, +99, 0xFF | Supports dec, hex, oct, bin. Underscores allowed for readability. |
| Float | 3.14, inf, nan | Must have a digit before and after the decimal point. |
| Boolean | true, false | Always lowercase. |
| Offset Date-Time | 1979-05-27T07:32:00Z | RFC 3339 format. |
| Local Date | 1979-05-27 | No time or timezone component. |
| Local Time | 07:32:00 | No date or timezone component. |
| Array | [1, 2, 3] | Mixed types are allowed in TOML v1.0.0. |
| Inline Table | {a = 1, b = 2} | Must be written on a single logical line. |
How the parsing works
The validator processes your input line by line. First, it strips comments (anything after an unquoted #) and handles multiline basic strings and multiline literal strings, which can span several physical lines. Then it classifies each logical line as empty, a table header ([...]), an array of tables header ([[...]]), or a key-value pair.
For key-value pairs, the parser splits the line at the first unquoted equals sign. It then validates the key path (which may include dots for nested keys) and attempts to parse the value according to the type rules. If the value starts with a quote, it parses a string. If it starts with a bracket, it recursively parses an array. If it starts with a brace, it parses an inline table. Otherwise, it matches against patterns for numbers, booleans, and dates.
A context object tracks the current table path. When a new [table] header is encountered, the context updates. The validator checks this context to ensure no key or table is redefined illegally.
Worked examples
| Example | Input | Result |
|---|---|---|
| Valid basic document | TOML input: title = "My Config" / [owner] / name = "Alice" / enabled = true | Valid TOML. |
| Missing closing quote | TOML input: name = "Alice / count = 5 | Line 1: Unterminated string (a basic string cannot contain a line break; use """ for multi-line) |
| Array of tables | TOML input: [[products]] / name = "Hammer" / sku = 738594937 / [[products]] / name = "Nail" / sku = 284758392 | Valid TOML. |
| Duplicate key error | TOML input: name = "first" / name = "second" | Line 2: Duplicate key "name" |
FAQ
Is my configuration data sent to a server?
No. This toml validator runs entirely in your browser using JavaScript. Your text is never uploaded anywhere.
Which version of TOML does this support?
It validates against the TOML v1.0.0 specification, which is the current stable version used by most modern tools and languages.
Can I validate multiline strings?
Yes. The parser correctly handles both multiline basic strings delimited by three double quotes and multiline literal strings delimited by three single quotes.
Why does it say duplicate key when my keys are in different tables?
Keys are scoped to their parent table. If you define the same key twice under the exact same table header without creating a new sub-table, it is considered a duplicate.
Does it support mixed-type arrays?
Yes. TOML v1.0.0 allows arrays to contain mixed data types, such as [1, "two", 3.0], and this validator accepts them.
What is the difference between a table and an inline table?
A standard table uses a header like [server] and spans multiple lines. An inline table uses braces like server = {ip = "127.0.0.1"} and must be completed on a single line.