TOML 07 ๐ TOML v1.0.0 Specification Details and Corner Cases
TOML v1.0.0 was published in January 2021, and it is the version that most production parsers implement. Python’s tomllib, Go’s go-toml/v2, and most language libraries target 1.0.0 rather than the newer 1.1.0 . The specification is shortโa single pageโbut it contains corner cases that produce parse errors or surprising data when violated. The goal of this chapter is to cover the details that the earlier chapters summarized: the exact rules for integers, the string escape restrictions, the inline-table single-line rule, and the table redefinition constraints that parsers enforce.
This chapter covers the v1.0.0 specification’s corner cases: integer bounds and leading zeros, the string forms and their escape restrictions, the inline-table single-line rule that 1.1.0 relaxed, and the table definition constraints that produce redefinition errors. The sections that follow walk through the scalar rules, the collection rules, and the table rules that determine what parses and what fails.
Key point: TOML v1.0.0 is the version most parsers implement; its corner cases include int64 bounds on integers, forbidden leading zeros, no newlines or trailing commas in inline tables, and the prohibition on defining a table more than once.
a. Integer and float corner cases
The specification requires that arbitrary 64-bit signed integers (from โ2^63 to 2^63โ1) be accepted and handled losslessly. If an integer cannot be represented losslessly, an error must be thrown . This is a hard bound, not a suggestion. A parser that saturates an out-of-range integer instead of rejecting it is non-compliant, and libraries have had to change their behavior to enforce it .
Leading zeros are forbidden in decimal integers. 0644 is invalid; 0o644 is the octal form, and 0 itself is valid . The -0 and +0 forms are valid and equal to 0. Underscores may separate digits, but each underscore must be surrounded by digits: 1_000 is valid, _1000 and 1000_ are not.
# Valid integers
int1 = +99
int2 = 42
int3 = 0
int4 = -17
hex = 0xDEADBEEF
oct = 0o755
bin = 0b11010110
separated = 1_000_000
# INVALID: leading zero
# invalid = 0644
# INVALID: underscore placement
# bad = _1000
Floats require a decimal point with digits on both sides, or an exponent, or both. .7, 7., and 3.e+20 are all invalid because the point lacks a digit on one side . The special values inf and nan are lowercase only; Inf and NaN are strings, not floats.
b. String escape restrictions
Basic strings process escapes; literal strings do not. The escape set in v1.0.0 is \b, \t, \n, \f, \r, \", \\, \uXXXX, and \UXXXXXXXX. Any other escape sequence is reserved and must produce an error . This means \a, \x, and \/ are not valid in v1.0.0 basic strings.
# Valid escapes
basic = "Line one\nLine two"
unicode = "Jos\u00E9"
quote = "She said \"hello\""
# INVALID: \x and \a are reserved in v1.0.0
# invalid = "\x41"
# invalid = "\a"
Multi-line basic strings trim the newline immediately after the opening delimiter. Other whitespace and newlines are preserved. A line-ending backslash removes the backslash, the newline, and all following whitespace until the next non-whitespace character . This is the line-continuation mechanism.
# The newline after """ is trimmed
multi = """
Line one
Line two"""
# Line-ending backslash joins lines
joined = """\
The quick brown \
fox jumps over \
the lazy dog.\
"""
Multi-line basic strings allow one or two adjacent quotes inside the string, but not three. A sequence of three quotes would close the string. To write three quotes inside, escape at least one of them .
Literal strings use single quotes and process no escapes. A single quote cannot appear in a single-line literal string. The multi-line literal form uses triple single quotes and allows one or two adjacent single quotes inside, but not three .
c. Inline tables and table redefinition
In TOML v1.0.0, inline tables must appear on a single line. No newlines are allowed between the braces unless they are valid within a value, and a trailing comma is not permitted after the last key/value pair . This is the rule that TOML 1.1.0 relaxed in December 2025, allowing multi-line inline tables and trailing commas . A parser targeting 1.0.0 rejects the multi-line form.
# VALID in 1.0.0: single line, no trailing comma
point = { x = 1, y = 2 }
# INVALID in 1.0.0: newlines inside braces
# point = {
# x = 1,
# y = 2
# }
# INVALID in 1.0.0: trailing comma
# point = { x = 1, y = 2, }
Tables cannot be defined more than once. A second [fruit] header is invalid. The root table is unnamed and ends at the first table header; it cannot be reopened . Dotted keys create tables implicitly, and those tables cannot later be opened with a [table] header. The exception is that a [table] header can define a new sub-table within a table created by dotted keys, as long as the sub-table itself has not been created.
# VALID: dotted keys create tables
fruit.apple.color = "red"
# VALID: new sub-table inside dotted-key table
[fruit.apple.texture]
smooth = true
# INVALID: redefining a table created by dotted keys
# [fruit.apple]
Arrays of tables ([[name]]) append to an array. A table header ([name]) cannot be used to add keys to an array of tables, and an array of tables cannot be converted to a regular table .
Complete Example Session
# ============================================
# PART 1: INTEGER BOUNDS AND FORMATS
# ============================================
safe = 9_223_372_036_854_775_807 # int64 max
hex = 0xDEADBEEF
oct = 0o755
bin = 0b11010110
# INVALID: out of int64 range
# too_big = 9_223_372_036_854_775_808
# INVALID: leading zero
# bad_octal = 0644
# ============================================
# PART 2: STRING ESCAPES
# ============================================
valid_escapes = "tab:\t newline:\n unicode:\u00E9"
# INVALID: \x is reserved in v1.0.0
# invalid_escape = "\x41"
# Multi-line with line continuation
joined = """\
first line \
second line\
"""
# ============================================
# PART 3: INLINE TABLE SINGLE-LINE RULE
# ============================================
valid_inline = { x = 1, y = 2 }
# INVALID in v1.0.0: newlines and trailing comma
# invalid_inline = {
# x = 1,
# y = 2,
# }
# ============================================
# PART 4: TABLE REDEFINITION
# ============================================
[valid_table]
key = "value"
# INVALID: same table defined twice
# [valid_table]
# other = "value"
# Dotted keys create tables
dotted.key = "value"
# INVALID: reopen dotted-key table
# [dotted]
The parts covered integer bounds and formats, string escape restrictions, the inline-table single-line rule, and the table redefinition constraints.
Quick Reference
Integer Rules
| Rule | Detail |
|---|---|
| Range | โ2^63 to 2^63โ1, lossless or error |
| Leading zero | Forbidden in decimal |
-0 / +0 | Valid, equal to 0 |
| Underscore | Between digits only |
| Prefixes | 0x, 0o, 0b |
String Escape Rules (v1.0.0)
| Escape | Valid |
|---|---|
\b, \t, \n, \f, \r | Yes |
\", \\ | Yes |
\uXXXX, \UXXXXXXXX | Yes |
\xHH, \e | No (added in 1.1.0) |
| Other sequences | Reserved, error |
Inline Table Rules (v1.0.0)
| Rule | Detail |
|---|---|
| Single line | Newlines forbidden |
| Trailing comma | Forbidden |
| Multi-line | Added in 1.1.0 |
Table Rules
| Rule | Detail |
|---|---|
| Redefinition | Invalid |
| Root table | Unnamed, closes at first header |
| Dotted-key tables | Cannot reopen with header |
| Sub-table of dotted-key table | Valid if new |
Best Practices
โ Do This:
# Keep inline tables on one line (v1.0.0)
point = { x = 1, y = 2 } # โ
# Use prefixed octal
mode = 0o755 # โ
# Quote ambiguous strings
version = "1.10" # โ
# Define each table once
[server]
port = 8080 # โ
โ Don’t Do This:
# Multi-line inline table (1.0.0)
# point = {
# x = 1 # โ
# }
# Leading zero in decimal
# bad = 0644 # โ
# Reserved escape
# bad = "\x41" # โ
# Redefine a table
# [server]
# other = "value" # โ
Common Pitfalls
| Pitfall | Why It Happens | Fix |
|---|---|---|
| Out-of-range integer accepted | Parser saturates instead of error | Use a compliant parser |
\x escape rejected | v1.0.0 reserves it | Use \uXXXX or upgrade to 1.1.0 parser |
| Multi-line inline table fails | v1.0.0 single-line rule | Keep on one line or use 1.1.0 |
| Table redefinition error | Same header twice | Combine into one section |
| Leading zero octal fails | Decimal leading zero forbidden | Use 0o755 |
Real-World Examples
1. Int64 max
max = 9_223_372_036_854_775_807
2. Octal mode
mode = 0o755
3. Valid unicode escape
name = "Jos\u00E9"
4. Line continuation
text = """\
joined lines\
"""
5. Single-line inline table
point = { x = 1, y = 2 }
6. Table defined once
[server]
port = 8080
7. Dotted key
fruit.apple.color = "red"
8. Sub-table of dotted-key table
[fruit.apple.texture]
smooth = true
9. Invalid escape (commented)
# bad = "\x41"
10. Invalid redefinition (commented)
# [server]
# other = "value"
Visual
Integer Bounds
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ INT64 RANGE โ
โ โ
โ โ2^63 โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 2^63โ1 โ
โ โ9,223,372,036,854,775,808 ... 9,223,372,036,854,775,807 โ
โ โ
โ Values outside: error, not saturation โ
โ โ
โ Leading zero: invalid โ
โ 0644 โ error โ
โ 0o644 โ valid octal โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
String Escape Sets
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ v1.0.0 v1.1.0 โ
โ โ
โ \b \t \n \f \r adds \xHH and \e โ
โ \" \\ \uXXXX \UXXXXXXXX โ
โ โ
โ \x41 โ error \x41 โ "A" โ
โ \e โ error \e โ escape char โ
โ โ
โ v1.0.0 rejects; v1.1.0 accepts โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Inline Table Rule Change
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ v1.0.0: SINGLE LINE ONLY โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ point = { x = 1, y = 2 } โ โ โ
โ โ point = { โ โ โ
โ โ x = 1, โ โ
โ โ y = 2 โ โ
โ โ } โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ v1.1.0: MULTI-LINE AND TRAILING COMMA ALLOWED โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ point = { โ โ โ
โ โ x = 1, โ โ
โ โ y = 2, # trailing comma โ โ
โ โ } โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Table Redefinition
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ VALID โ
โ โ
โ [fruit] โ
โ apple = "red" โ
โ โ
โ [fruit.apple.texture] โโโ new sub-table โ
โ smooth = true โ
โ โ
โ INVALID โ
โ โ
โ [fruit] โ
โ apple = "red" โ
โ โ
โ [fruit] โโโ redefinition โ
โ orange = "orange" โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Summary
| Item | Value |
|---|---|
| v1.0.0 release | January 2021 |
| Parser target | Most production parsers |
| Integer range | int64, lossless or error |
| Leading zero | Forbidden |
| Escape set | \b \t \n \f \r \" \\ \uXXXX \UXXXXXXXX |
| Reserved escapes | Error in v1.0.0 |
| Inline table | Single line, no trailing comma |
| Table redefinition | Invalid |
Key takeaways:
- TOML v1.0.0 is the version most parsers implement. Python’s
tomllibparses 1.0.0; 1.1.0 support is planned for a later Python release . The corner cases below apply to the files most tools read. - Integers are bounded to int64 and must be lossless. A parser that saturates an out-of-range value is non-compliant; the specification requires an error .
- The escape set is closed in v1.0.0. Any sequence not in the list is reserved and must produce an error.
\xand\eare 1.1.0 additions . - Inline tables are single-line in v1.0.0. The multi-line and trailing-comma forms are 1.1.0 features. A file using them will fail on a 1.0.0 parser .
- Tables are defined once. A second header for the same table is an error, and dotted-key tables cannot be reopened with a header. The exception is a new sub-table inside a dotted-key table .
Remember: TOML’s syntax is small, but the corner cases are where parsers diverge. The integer bounds, the escape set, the inline-table single-line rule, and the table redefinition constraints are all specified, and all are enforced by compliant parsers. When a file fails to parse, check the version first: a 1.1.0 feature in a 1.0.0 parser produces an error that looks like a syntax mistake but is a version mismatch. Write files that target the parser’s version, and when in doubt, use the conservative form: single-line inline tables, explicit 0o octals, and no reserved escapes.
Stop using slow, ad-bloated tool sites! ๐คฎ
๐ Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
โ
Finance (Mortgage, Interest, Inflation)
โ
Tech (Base64, JSON, Dev Suite, IP)
โ
Health (BMI, BMR, TDEE)
โ
Productivity (Timer, Workspace, QR)
โก๏ธ Fast & Private
๐ No data leaves your device
๐ 100% Free
๐ Use it now: https://tools.kandz.me
๐ Bookmark itโyouโll need it later!