Xerobit

TOML Validator: Check TOML Syntax Instantly

Paste your TOML document to check its syntax and find errors. This toml validator parses keys, values, tables, and arrays of tables according to the v1.0.0 specification, reporting the exact line number and reason for any failure. It runs entirely in your browser so nothing is uploaded.

Supports TOML v1.0.0 syntax including tables, arrays, strings, integers, floats, booleans, dates, and inline tables.

Result

Valid TOML (empty document).

How to use the toml validator

  1. Paste or type your TOML document into the text area.
  2. The toml validator checks the syntax automatically as you type.
  3. If the document is valid, a success message appears below the input.
  4. If there is an error, read the reported line number and description to fix it.
  5. 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 = Alice instead of name = "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 = 80 twice 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 \n or \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.

TypeExampleNotes
String"hello", 'world'Basic strings allow escapes; literal strings do not.
Integer42, +99, 0xFFSupports dec, hex, oct, bin. Underscores allowed for readability.
Float3.14, inf, nanMust have a digit before and after the decimal point.
Booleantrue, falseAlways lowercase.
Offset Date-Time1979-05-27T07:32:00ZRFC 3339 format.
Local Date1979-05-27No time or timezone component.
Local Time07:32:00No 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

ExampleInputResult
Valid basic documentTOML input: title = "My Config" / [owner] / name = "Alice" / enabled = trueValid TOML.
Missing closing quoteTOML input: name = "Alice / count = 5Line 1: Unterminated string (a basic string cannot contain a line break; use """ for multi-line)
Array of tablesTOML input: [[products]] / name = "Hammer" / sku = 738594937 / [[products]] / name = "Nail" / sku = 284758392Valid TOML.
Duplicate key errorTOML 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.