| | |

TOML 07 ๐Ÿ“„ TOML v1.0.0 Specification Details and Corner Cases

โฑ๏ธ Estimated read: 8 min | |

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

RuleDetail
Rangeโˆ’2^63 to 2^63โˆ’1, lossless or error
Leading zeroForbidden in decimal
-0 / +0Valid, equal to 0
UnderscoreBetween digits only
Prefixes0x, 0o, 0b

String Escape Rules (v1.0.0)

EscapeValid
\b, \t, \n, \f, \rYes
\", \\Yes
\uXXXX, \UXXXXXXXXYes
\xHH, \eNo (added in 1.1.0)
Other sequencesReserved, error

Inline Table Rules (v1.0.0)

RuleDetail
Single lineNewlines forbidden
Trailing commaForbidden
Multi-lineAdded in 1.1.0

Table Rules

RuleDetail
RedefinitionInvalid
Root tableUnnamed, closes at first header
Dotted-key tablesCannot reopen with header
Sub-table of dotted-key tableValid 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

PitfallWhy It HappensFix
Out-of-range integer acceptedParser saturates instead of errorUse a compliant parser
\x escape rejectedv1.0.0 reserves itUse \uXXXX or upgrade to 1.1.0 parser
Multi-line inline table failsv1.0.0 single-line ruleKeep on one line or use 1.1.0
Table redefinition errorSame header twiceCombine into one section
Leading zero octal failsDecimal leading zero forbiddenUse 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

ItemValue
v1.0.0 releaseJanuary 2021
Parser targetMost production parsers
Integer rangeint64, lossless or error
Leading zeroForbidden
Escape set\b \t \n \f \r \" \\ \uXXXX \UXXXXXXXX
Reserved escapesError in v1.0.0
Inline tableSingle line, no trailing comma
Table redefinitionInvalid

Key takeaways:

  • TOML v1.0.0 is the version most parsers implement. Python’s tomllib parses 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. \x and \e are 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.

Was this helpful?


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!