This page follows the TOML 1.0.0
specification (released 2021-01-11) and its
ABNF grammar, read
2026-11-12. A TOML document must be valid UTF-8, is designed to map unambiguously to a
hash table, and the specification gives the extension .toml and the media
type application/toml. TOML 1.1.0 followed on 2025-12-18 (see the
changelog, read
2026-11-12); its changes are listed at the end of this page.
Basics
- White space is tab (0x09) or space (0x20); a newline is LF (0x0A) or CR LF (0x0D 0x0A).
#starts a comment to the end of the line (not inside strings). The prose says control characters other than tab (U+0000 to U+0008, U+000A to U+001F, U+007F) are not permitted in comments; the 1.0.0 ABNF’snon-eol = %x09 / %x20-7F / non-asciidoes admit U+007F.- A key/value pair is
key = value; the key, the equals sign and the value must be on the same line (some values can span lines), and a newline or end of file must follow. A key with no value is invalid.
Keys
| Kind | Form |
|---|---|
| Bare | ASCII letters, digits, _ and -, at least one character: bare_key, 1234 (always a string). |
| Quoted | A basic or literal string: "ʎǝʞ", 'key2'. "" is allowed but discouraged. |
| Dotted | Keys joined by dots, which create nested tables: site."google.com" = true. White space around the dots is ignored; 3.14159 is two keys. |
Defining the same key twice is invalid (a bare key and the same key quoted are equivalent), as is giving a key a value and then using it as a table.
Strings
| Kind | Delimiters | Rules |
|---|---|---|
| Basic | "…" | Escapes allowed; one line. |
| Multi-line basic | """…""" | A new line straight after the opening quotes is dropped. A backslash at the end of a line removes the line break and the white space after it. |
| Literal | '…' | No escapes; one line. |
| Multi-line literal | '''…''' | No escapes; first new line dropped. One or two single quotes may appear inside, never three in a row. |
Escapes: \b, \t, \n, \f,
\r, \", \\, \uXXXX and
\UXXXXXXXX (the code must be a Unicode scalar value). All other escape
sequences are reserved, and TOML should produce an error if one is used. In basic
strings the quotation mark, backslash and control characters other than tab must be
escaped; multi-line basic strings also allow raw LF and CR, but a carriage return (U+000D)
is allowed only as part of a newline sequence (CR LF), never alone. In literal strings
('...' and '''...''') control characters other than tab are
not permitted (multi-line literal strings, like multi-line basic ones, also take
newlines), and there are no escapes. Multi-line strings cannot be used to define
quoted keys: """key""" = 1 is invalid; a key's quotes must be a single
" or '.
Numbers and booleans
- Integers:
+99,-17,1_000(each underscore between digits),0xDEADBEEF,0o755,0b11010110. No leading zeros in decimal; hex, octal and binary are for non-negative values, take no leading+, and may have leading zeros after the prefix. The range −263 to 263−1 should be accepted losslessly; an integer that cannot be represented losslessly must be an error. - Floats should be IEEE 754 binary64:
3.1415,-0.01,5e+22,6.626e-34; a decimal point needs digits on both sides. Special values (always lower case)inf,+inf,-inf,nan,+nan,-nan. - Booleans:
trueandfalse, lower case.
Dates and times
| Type | Example |
|---|---|
| Offset date-time (RFC 3339) | 1979-05-27T07:32:00Z, 1979-05-27T00:32:00.999999-07:00; a space may replace the T. |
| Local date-time | 1979-05-27T07:32:00 |
| Local date | 1979-05-27 |
| Local time | 07:32:00, 00:32:00.999999 |
Millisecond precision is required for fractional seconds; further precision is implementation-specific, and digits beyond what an implementation supports must be truncated, not rounded.
Arrays and tables
- Arrays:
[ 1, 2, 3 ], values of any types mixed, new lines and comments allowed between values, a trailing comma allowed. - Tables: a header
[name](dotted or quoted keys allowed) followed by its pairs until the next header. A table may be defined only once; defining[a.b]first and[a]later is allowed. - Inline tables:
{ x = 1, y = 2 }, intended to appear on one line (no newlines between the braces unless valid within a value), no trailing comma. They are self-contained: keys and sub-tables cannot be added outside the braces. - Arrays of tables: each
[[name]]header adds a new table to the arrayname; following[name.sub]headers belong to its last element.
[[products]]
name = "Hammer"
sku = 738594937
[[products]] # empty table within the array
[[products]]
name = "Nail"
sku = 284758393
color = "gray"
That is the specification’s example. Appending with [[name]] to an
array defined statically (name = [ … ]) is an error, as is reusing a
name as both a table and an array of tables.
Number, key and table rules of TOML 1.0.0
From the 1.0.0 specification text (toml.md) and toml.abnf,
read 2026-11-13.
- Decimal integers: no leading zeros;
-0and+0are valid and equal to0. Underscores between digits, each with a digit on both sides (53_49_221). Hex, octal and binary integers (0x,0o,0b) are non-negative, have no leading+, allow leading zeros after the prefix, hex digits in either case, and underscores between digits but not between the prefix and the value. - Floats: an integer part, then a fractional part (a point and one or more digits), an exponent, or both. The point needs a digit on each side (
.7,7.and3.e+20are invalid). The exponent iseorEand an integer that follows the integer rules but may have leading zeros (1e06). Underscores follow the integer rule (224_617.445_991_228).-0.0and+0.0are valid and map as in IEEE 754.inf,+inf,-inf,nan,+nan,-nanare lower case. - Keys: a bare key is non-empty (
A-Za-z0-9_-, and may be all digits yet is always a string); an empty quoted key ("" = "blank") is valid but discouraged;= "no key name"is invalid. Whitespace around a key and around the dots of a dotted key is ignored. - Tables: a header sets the table for the key/value pairs under it until the next header or the end; pairs within a table have no guaranteed order. Whitespace inside the brackets is ignored (
[ d.e.f ]is[d.e.f]), as is indentation. Empty tables are allowed. Super-tables need not be written:[x.y.z.w]createsx,x.yandx.y.z, and[x]may follow. The root table starts at the document's beginning, ends before the first header, is nameless and cannot be moved. Out-of-order tables are valid but discouraged. - Redefinition: a table cannot be defined twice (
[fruit]twice, or[fruit]with[fruit.apple]whenappleis a key, is invalid). Dotted keys create and define a table for each part before the last, if not already created; a later[table]header cannot redefine such a table, nor can dotted keys redefine a table defined in[table]form; but[table]may define sub-tables of a dotted-key table ([fruit.apple.texture]afterapple.color = "red"). - Arrays of tables: if the parent of a table or array of tables is an array element, that element must already be defined;
[fruit.physical]before[[fruit]]is a parse error. Appending to a statically defined array, even an empty one (fruits = []then[[fruits]]), is an error, as is defining a normal table with the name of an established array of tables or the reverse.
The 1.0.0 ABNF
toml = expression *( newline expression )
expression = ws [ comment ]
expression =/ ws keyval ws [ comment ]
expression =/ ws table ws [ comment ]
ws = *wschar
wschar = %x20 / %x09
newline = %x0A / %x0D.0A
comment-start-symbol = %x23
non-ascii = %x80-D7FF / %xE000-10FFFF
non-eol = %x09 / %x20-7F / non-ascii
comment = comment-start-symbol *non-eol
keyval = key keyval-sep val
key = simple-key / dotted-key
simple-key = quoted-key / unquoted-key
unquoted-key = 1*( ALPHA / DIGIT / %x2D / %x5F )
quoted-key = basic-string / literal-string
dotted-key = simple-key 1*( dot-sep simple-key )
dot-sep = ws %x2E ws
keyval-sep = ws %x3D ws
val = string / boolean / array / inline-table / date-time / float / integer
string = ml-basic-string / basic-string / ml-literal-string / literal-string
basic-string = quotation-mark *basic-char quotation-mark
quotation-mark = %x22
basic-char = basic-unescaped / escaped
basic-unescaped = wschar / %x21 / %x23-5B / %x5D-7E / non-ascii
escaped = escape escape-seq-char
escape = %x5C
escape-seq-char = %x22 / %x5C / %x62 / %x66 / %x6E / %x72 / %x74
escape-seq-char =/ %x75 4HEXDIG / %x55 8HEXDIG
ml-basic-string = ml-basic-string-delim [ newline ] ml-basic-body ml-basic-string-delim
ml-basic-string-delim = 3quotation-mark
ml-basic-body = *mlb-content *( mlb-quotes 1*mlb-content ) [ mlb-quotes ]
mlb-content = mlb-char / newline / mlb-escaped-nl
mlb-char = mlb-unescaped / escaped
mlb-quotes = 1*2quotation-mark
mlb-unescaped = wschar / %x21 / %x23-5B / %x5D-7E / non-ascii
mlb-escaped-nl = escape ws newline *( wschar / newline )
literal-string = apostrophe *literal-char apostrophe
apostrophe = %x27
literal-char = %x09 / %x20-26 / %x28-7E / non-ascii
ml-literal-string = ml-literal-string-delim [ newline ] ml-literal-body ml-literal-string-delim
ml-literal-string-delim = 3apostrophe
ml-literal-body = *mll-content *( mll-quotes 1*mll-content ) [ mll-quotes ]
mll-content = mll-char / newline
mll-char = %x09 / %x20-26 / %x28-7E / non-ascii
mll-quotes = 1*2apostrophe
integer = dec-int / hex-int / oct-int / bin-int
minus = %x2D plus = %x2B underscore = %x5F
digit1-9 = %x31-39 digit0-7 = %x30-37 digit0-1 = %x30-31
hex-prefix = %x30.78 oct-prefix = %x30.6F bin-prefix = %x30.62
dec-int = [ minus / plus ] unsigned-dec-int
unsigned-dec-int = DIGIT / digit1-9 1*( DIGIT / underscore DIGIT )
hex-int = hex-prefix HEXDIG *( HEXDIG / underscore HEXDIG )
oct-int = oct-prefix digit0-7 *( digit0-7 / underscore digit0-7 )
bin-int = bin-prefix digit0-1 *( digit0-1 / underscore digit0-1 )
float = float-int-part ( exp / frac [ exp ] )
float =/ special-float
float-int-part = dec-int
frac = decimal-point zero-prefixable-int
decimal-point = %x2E
zero-prefixable-int = DIGIT *( DIGIT / underscore DIGIT )
exp = "e" float-exp-part
float-exp-part = [ minus / plus ] zero-prefixable-int
special-float = [ minus / plus ] ( inf / nan )
inf = %x69.6e.66 nan = %x6e.61.6e
boolean = true / false
true = %x74.72.75.65 false = %x66.61.6C.73.65
date-time = offset-date-time / local-date-time / local-date / local-time
date-fullyear = 4DIGIT date-month = 2DIGIT date-mday = 2DIGIT
time-delim = "T" / %x20
time-hour = 2DIGIT time-minute = 2DIGIT time-second = 2DIGIT
time-secfrac = "." 1*DIGIT
time-numoffset = ( "+" / "-" ) time-hour ":" time-minute
time-offset = "Z" / time-numoffset
partial-time = time-hour ":" time-minute ":" time-second [ time-secfrac ]
full-date = date-fullyear "-" date-month "-" date-mday
full-time = partial-time time-offset
offset-date-time = full-date time-delim full-time
local-date-time = full-date time-delim partial-time
local-date = full-date
local-time = partial-time
array = array-open [ array-values ] ws-comment-newline array-close
array-open = %x5B array-close = %x5D
array-values = ws-comment-newline val ws-comment-newline array-sep array-values
array-values =/ ws-comment-newline val ws-comment-newline [ array-sep ]
array-sep = %x2C
ws-comment-newline = *( wschar / [ comment ] newline )
table = std-table / array-table
std-table = std-table-open key std-table-close
std-table-open = %x5B ws
std-table-close = ws %x5D
inline-table = inline-table-open [ inline-table-keyvals ] inline-table-close
inline-table-open = %x7B ws
inline-table-close = ws %x7D
inline-table-sep = ws %x2C ws
inline-table-keyvals = keyval [ inline-table-sep inline-table-keyvals ]
array-table = array-table-open key array-table-close
array-table-open = %x5B.5B ws
array-table-close = ws %x5D.5D
ALPHA = %x41-5A / %x61-7A DIGIT = %x30-39 HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
The ABNF is condensed here (some alternatives of one rule share a line and the comments are dropped). Every document that is valid TOML matches it, but some invalid documents also match, and the supporting text rejects them (such as redefined tables).
Changes in TOML 1.1.0
The changelog lists these changes for 1.1.0 (2025-12-18):
- Inline tables may contain newlines and a trailing comma.
- Basic strings gain
\xHHfor code points up to 255 and\efor the escape character. - Seconds are optional in date-time and time values
(
2010-02-03 14:15,14:15). - Clarifications: comments never affect the tables produced; Unicode and UTF-8
references; where and how dotted keys define tables; newline normalisation in
multi-line literal strings; sub-millisecond precision is allowed; parsers are free
to support any integer or float size. The prose rules behind the first two, stated
in full in 1.1.0 (Preliminaries and Table):
- Ill-formed UTF-8. A TOML file must be a valid UTF-8 document, meaning the file as a whole must form a well-formed code-unit sequence. Otherwise a parser must reject it (preferably) or replace the ill-formed byte sequences with U+FFFD, as the Unicode specification describes.
- Dotted-key tables. A dotted key creates and defines a table
for each key part before the last one. Any such table must have all its
key/value pairs defined under the current
[table]header, or in the root table if they come before all headers, or in one inline table; they cannot be split across other places.
Comparing toml.abnf at tag 1.0.0 with the file on the main branch (both
downloaded 2026-11-13, compared with diff), the grammar differences are
exactly these:
non-eolis%x09 / %x20-7E / non-ascii(1.0.0 had%x20-7F), so U+007F is no longer allowed in comments.escape-seq-chargains%x65(e, U+001B) and%x78 2HEXDIG(xHH, U+00HH).mlb-contentusesbasic-charandmll-contentusesliteral-char; the rulesmlb-char,mlb-unescapedandmll-charare gone (same character sets).partial-time = time-hour ":" time-minute [ ":" time-second [ time-secfrac ] ]: seconds are optional.inline-tableisinline-table-open [ inline-table-keyvals ] ws-comment-newline inline-table-close;inline-table-open,-closeand-sepno longer carryws; andinline-table-keyvalsis now two alternatives, the firstws-comment-newline keyval ws-comment-newline inline-table-sep inline-table-keyvals, the secondws-comment-newline keyval ws-comment-newline [ inline-table-sep ](so a trailing comma, comments and newlines are allowed).- The
valrule moved up in the file,infandnanuse upper-case hex digits, and the 1.1.0 header comment says the grammar refers to the code points obtained after decoding the UTF-8 input. No meaning changes.
The 1.1.0 ABNF (whole grammar, condensed)
toml = expression *( newline expression )
expression = ws [ comment ]
expression =/ ws keyval ws [ comment ]
expression =/ ws table ws [ comment ]
ws = *wschar
wschar = %x20 / %x09
newline = %x0A / %x0D.0A
comment-start-symbol = %x23
non-ascii = %x80-D7FF / %xE000-10FFFF
non-eol = %x09 / %x20-7E / non-ascii
comment = comment-start-symbol *non-eol
keyval = key keyval-sep val
key = simple-key / dotted-key
val = string / boolean / array / inline-table / date-time / float / integer
simple-key = quoted-key / unquoted-key
unquoted-key = 1*( ALPHA / DIGIT / %x2D / %x5F )
quoted-key = basic-string / literal-string
dotted-key = simple-key 1*( dot-sep simple-key )
dot-sep = ws %x2E ws
keyval-sep = ws %x3D ws
string = ml-basic-string / basic-string / ml-literal-string / literal-string
basic-string = quotation-mark *basic-char quotation-mark
quotation-mark = %x22
basic-char = basic-unescaped / escaped
basic-unescaped = wschar / %x21 / %x23-5B / %x5D-7E / non-ascii
escaped = escape escape-seq-char
escape = %x5C
escape-seq-char = %x22 / %x5C / %x62 / %x65 / %x66 / %x6E / %x72 / %x74
escape-seq-char =/ %x78 2HEXDIG ; xHH U+00HH
escape-seq-char =/ %x75 4HEXDIG ; uHHHH U+HHHH
escape-seq-char =/ %x55 8HEXDIG ; UHHHHHHHH U+HHHHHHHH
ml-basic-string = ml-basic-string-delim [ newline ] ml-basic-body ml-basic-string-delim
ml-basic-string-delim = 3quotation-mark
ml-basic-body = *mlb-content *( mlb-quotes 1*mlb-content ) [ mlb-quotes ]
mlb-content = basic-char / newline / mlb-escaped-nl
mlb-quotes = 1*2quotation-mark
mlb-escaped-nl = escape ws newline *( wschar / newline )
literal-string = apostrophe *literal-char apostrophe
apostrophe = %x27
literal-char = %x09 / %x20-26 / %x28-7E / non-ascii
ml-literal-string = ml-literal-string-delim [ newline ] ml-literal-body ml-literal-string-delim
ml-literal-string-delim = 3apostrophe
ml-literal-body = *mll-content *( mll-quotes 1*mll-content ) [ mll-quotes ]
mll-content = literal-char / newline
mll-quotes = 1*2apostrophe
integer = dec-int / hex-int / oct-int / bin-int
minus = %x2D plus = %x2B underscore = %x5F
digit1-9 = %x31-39 digit0-7 = %x30-37 digit0-1 = %x30-31
hex-prefix = %x30.78 oct-prefix = %x30.6F bin-prefix = %x30.62
dec-int = [ minus / plus ] unsigned-dec-int
unsigned-dec-int = DIGIT / digit1-9 1*( DIGIT / underscore DIGIT )
hex-int = hex-prefix HEXDIG *( HEXDIG / underscore HEXDIG )
oct-int = oct-prefix digit0-7 *( digit0-7 / underscore digit0-7 )
bin-int = bin-prefix digit0-1 *( digit0-1 / underscore digit0-1 )
float = float-int-part ( exp / frac [ exp ] )
float =/ special-float
float-int-part = dec-int
frac = decimal-point zero-prefixable-int
decimal-point = %x2E
zero-prefixable-int = DIGIT *( DIGIT / underscore DIGIT )
exp = "e" float-exp-part
float-exp-part = [ minus / plus ] zero-prefixable-int
special-float = [ minus / plus ] ( inf / nan )
inf = %x69.6E.66 nan = %x6E.61.6E
boolean = true / false
true = %x74.72.75.65 false = %x66.61.6C.73.65
date-time = offset-date-time / local-date-time / local-date / local-time
date-fullyear = 4DIGIT
date-month = 2DIGIT ; 01-12
date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on month/year
time-delim = "T" / %x20 ; the file's comment reads "T, t, or space"
time-hour = 2DIGIT ; 00-23
time-minute = 2DIGIT ; 00-59
time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second rules
time-secfrac = "." 1*DIGIT
time-numoffset = ( "+" / "-" ) time-hour ":" time-minute
time-offset = "Z" / time-numoffset
partial-time = time-hour ":" time-minute [ ":" time-second [ time-secfrac ] ]
full-date = date-fullyear "-" date-month "-" date-mday
full-time = partial-time time-offset
offset-date-time = full-date time-delim full-time
local-date-time = full-date time-delim partial-time
local-date = full-date
local-time = partial-time
array = array-open [ array-values ] ws-comment-newline array-close
array-open = %x5B array-close = %x5D
array-values = ws-comment-newline val ws-comment-newline array-sep array-values
array-values =/ ws-comment-newline val ws-comment-newline [ array-sep ]
array-sep = %x2C
ws-comment-newline = *( wschar / [ comment ] newline )
table = std-table / array-table
std-table = std-table-open key std-table-close
std-table-open = %x5B ws
std-table-close = ws %x5D
inline-table = inline-table-open [ inline-table-keyvals ] ws-comment-newline inline-table-close
inline-table-open = %x7B inline-table-close = %x7D inline-table-sep = %x2C
inline-table-keyvals = ws-comment-newline keyval ws-comment-newline inline-table-sep inline-table-keyvals
inline-table-keyvals =/ ws-comment-newline keyval ws-comment-newline [ inline-table-sep ]
array-table = array-table-open key array-table-close
array-table-open = %x5B.5B ws
array-table-close = ws %x5D.5D
ALPHA = %x41-5A / %x61-7A DIGIT = %x30-39 HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
Date and time value limits. The grammar only fixes digit counts; the comments in both the 1.0.0 and 1.1.0 files give the value ranges: month 01-12, day 01-28, 01-29, 01-30 or 01-31 depending on month and year (so February has 29 days in leap years only), hour 00-23, minute 00-59, and second 00-58, 00-59 or 00-60 depending on the leap-second rules (60 is the leap second). The grammar's own header comment says documents that match it may still be invalid under the supporting text.