TOML 04 ๐ Data Types โ Strings, Integers, Floats, Booleans, Dates/Times
TOML’s type system is small and explicit. Every value on the right side of an assignment must be one of ten types: string, integer, float, boolean, offset date-time, local date-time, local date, local time, array, or inline table . The scalar typesโstrings, numbers, booleans, and the four date/time formsโare the vocabulary of every configuration file, and each has rules that determine what parses and what fails. There is no implicit conversion: a quoted "42" is a string, an unquoted 42 is an integer, and the parser does not guess.
This chapter covers the scalar types and their syntax. It explains the four string forms and when each is appropriate, the integer and float formats including hexadecimal, octal, binary, and special values, the boolean literals, and the four date/time types that distinguish absolute instants from local wall-clock values. The sections that follow walk through strings, numbers, booleans, and dates/times, with the edge cases that cause parse errors.
Key point: TOML types are determined by syntax, not by content; a string is always quoted, a number is always bare, and the four date/time types are distinguished by whether they carry a timezone offset and whether they include a date, a time, or both.
Why explicit scalar types exist
The string-quoting problem. TOML strings must be quoted, which means a value that looks numeric is never accidentally numeric. version = "1.10" is a string and stays "1.10"; version = 1.10 is a float and becomes 1.1. This is the fix for the YAML version-truncation problem: the author’s intent is encoded in the syntax, not inferred by the parser .
The date/time distinction problem. TOML has four date/time types, not one. An offset date-time includes a timezone and represents an absolute instant. A local date-time has no timezone and represents a wall-clock value that cannot be converted to an instant without additional information. A local date is a day with no time. A local time is a time of day with no date . The distinction matters because a schedule that says “09:00 local time” is not the same as “09:00 UTC,” and conflating them produces bugs that only appear across timezones.
The escape problem. Basic strings support escape sequences for tabs, newlines, Unicode, and quotes; literal strings do not. A Windows path like C:\Users\name written as a basic string requires escaping every backslash. The literal form exists so that backslashes and regex patterns can be written exactly as they appear, without escape processing .
a. Strings: four forms
TOML has four string forms: basic, multi-line basic, literal, and multi-line literal. Basic strings use double quotes and process escape sequences. Literal strings use single quotes and process nothing.
# Basic string: escape sequences processed
basic = "Line one\nLine two"
escaped = "She said \"hello\""
unicode = "Jos\u00E9"
# Literal string: no escaping, backslashes literal
path = 'C:\Users\nodejs\templates'
regex = '<\i\c*\s*>'
Multi-line strings use triple delimiters. A newline immediately after the opening delimiter is trimmed. A line-ending backslash in a multi-line basic string trims the newline and all following whitespace, joining lines without introducing a space .
# Multi-line basic: newlines preserved, first newline trimmed
description = """
Line one
Line two"""
# Line-ending backslash joins lines
joined = """\
The quick brown \
fox jumps over \
the lazy dog.\
"""
The multi-line literal form (triple single quotes) is the escape hatch for strings containing both quotes and backslashes, such as regex patterns or shell scripts with embedded quotes.
b. Integers and floats
Integers are whole numbers with optional sign. They support decimal, hexadecimal (0x), octal (0o), and binary (0b) prefixes. Underscores may separate digits for readability, but each underscore must be surrounded by digits .
# Decimal integers
int1 = +99
int2 = 42
int3 = 0
int4 = -17
# Prefixed integers
hex = 0xDEADBEEF
oct = 0o755
bin = 0b11010110
# Digit separators
large = 1_000_000
A leading zero is not permitted in decimal integers, except for 0 itself. 0644 is invalid; 0o644 is the octal form if that is the intent.
Floats require a decimal point or an exponent (or both). They support inf, +inf, -inf, nan, +nan, and -nan as special values. Digit separators are allowed in the integer and fractional parts .
# Floats
float1 = +1.0
float2 = 3.1415
float3 = -0.01
# Exponent
float4 = 5e+22
float5 = 1e06
float6 = -2E-2
# Both
float7 = 6.626e-34
# Special values
infinite = inf
not_a_number = nan
c. Booleans and the four date/time types
Booleans are true and false, lowercase only. There are no yes/no/on/off aliases, and no capitalization variants.
enabled = true
debug = false
Date/time values follow RFC 3339 with TOML’s liberties: a space may replace the T separator, and fractional seconds may be any length . The four types are distinguished by their components.
# Offset date-time: absolute instant with timezone
odt1 = 1979-05-27T07:32:00Z
odt2 = 1979-05-27T00:32:00-07:00
odt3 = 1979-05-27T00:32:00.999999-07:00
# Local date-time: no timezone, wall-clock value
ldt1 = 1979-05-27T07:32:00
ldt2 = 1979-05-27T00:32:00.999999
# Local date: a day, no time
ld1 = 1979-05-27
# Local time: a time of day, no date
lt1 = 07:32:00
lt2 = 00:32:00.999999
The Z suffix and ยฑHH:MM offset mark an offset date-time. Without either, a value with both date and time is local. A value with only a date is a local date; only a time is a local time. Parsers return these as different types: JavaScript returns Date for offset date-times and strings for local forms, while Go uses distinct LocalDateTime, LocalDate, and LocalTime types .
Complete Example Session
# ============================================
# PART 1: STRINGS (FOUR FORMS)
# ============================================
basic = "Line one\nLine two"
literal = 'C:\Users\app'
multi_basic = """
Line one
Line two"""
multi_literal = '''
No \escaping here'''
# ============================================
# PART 2: INTEGERS
# ============================================
decimal = 42
negative = -17
hex = 0xDEADBEEF
octal = 0o755
binary = 0b11010110
separated = 1_000_000
# ============================================
# PART 3: FLOATS
# ============================================
pi = 3.1415
exponent = 5e+22
both = 6.626e-34
infinity = inf
nan_value = nan
# ============================================
# PART 4: BOOLEANS
# ============================================
enabled = true
debug = false
# ============================================
# PART 5: DATES AND TIMES
# ============================================
offset = 1979-05-27T07:32:00Z
local_dt = 1979-05-27T07:32:00
local_date = 1979-05-27
local_time = 07:32:00
# ============================================
# PART 6: THE PARSED TYPES
# ============================================
# basic: "Line one\nLine two" (string)
# literal: 'C:\Users\app' (string, backslashes preserved)
# decimal: 42 (integer)
# hex: 3735928559 (integer)
# pi: 3.1415 (float)
# enabled: true (boolean)
# offset: absolute instant (offset date-time)
# local_dt: wall-clock (local date-time, no timezone)
# local_date: a day (local date)
# local_time: a time of day (local time)
The parts covered the four string forms, integer formats, float formats with special values, booleans, the four date/time types, and the parsed type distinctions.
Quick Reference
String Forms
| Form | Delimiter | Escapes | Multi-line |
|---|---|---|---|
| Basic | "..." | Yes | No |
| Multi-line basic | """...""" | Yes | Yes |
| Literal | '...' | No | No |
| Multi-line literal | '''...''' | No | Yes |
Number Formats
| Type | Syntax | Notes |
|---|---|---|
| Decimal integer | 42, -17, +99 | No leading zero |
| Hex integer | 0xDEADBEEF | Case-insensitive digits |
| Octal integer | 0o755 | Prefix 0o |
| Binary integer | 0b11010110 | Prefix 0b |
| Float | 3.14, 5e+22 | Decimal point or exponent |
| Special floats | inf, -inf, nan | Lowercase only |
Date/Time Types
| Type | Example | Timezone |
|---|---|---|
| Offset date-time | 1979-05-27T07:32:00Z | Yes |
| Local date-time | 1979-05-27T07:32:00 | No |
| Local date | 1979-05-27 | No |
| Local time | 07:32:00 | No |
Best Practices
โ Do This:
# Quote strings that look like numbers
version = "1.10" # โ
# Use literal strings for paths and regex
path = 'C:\Users\app' # โ
# Use digit separators for large numbers
budget = 1_000_000 # โ
# Use offset date-time when the instant matters
created = 2026-05-05T10:00:00Z # โ
โ Don’t Do This:
# Leading zero in decimal integer
octal_wrong = 0644 # โ
# Unquoted string
name = app # โ (bare key error)
# Capitalized boolean
enabled = True # โ
# Date-time without timezone when instant is intended
created = 2026-05-05T10:00:00 # โ (local, not UTC)
Common Pitfalls
| Pitfall | Why It Happens | Fix |
|---|---|---|
0644 parse error | Leading zero forbidden | Use 0o644 for octal or quote as string |
| Path escape errors | Basic string processes \ | Use literal string '...' |
True rejected | Booleans lowercase only | Use true |
| Local date-time treated as UTC | No offset means local | Add Z or offset |
| Multi-line string has extra newline | Opening delimiter newline not trimmed in all parsers | Use \ at line end or accept trim behavior |
Real-World Examples
1. Version as string
version = "1.10"
2. Windows path as literal
path = 'C:\Users\app'
3. Regex as literal
pattern = '<\i\c*\s*>'
4. Hex color
color = 0xFF0000
5. Large number with separators
bytes = 1_073_741_824
6. Special float
timeout = inf
7. Offset date-time
created = 2026-05-05T10:00:00Z
8. Local date
birthday = 1990-01-15
9. Local time
alarm = 07:30:00
10. Multi-line description
description = """
Line one
Line two"""
Visual
String Form Decision
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CHOOSING A STRING FORM โ
โ โ
โ Contains backslashes or quotes? โ
โ โ โ
โ โโโโโโดโโโโโ โ
โ โผ โผ โ
โ YES NO โ
โ โ โ โ
โ โผ โผ โ
โ Literal Multi-line? โ
โ '...' โ โ
โ โโโโโดโโโโ โ
โ โผ โผ โ
โ YES NO โ
โ โ โ โ
โ โผ โผ โ
โ """...""" "..." โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The Four Date/Time Types
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ DATE/TIME DISAMBIGUATION โ
โ โ
โ Has date AND time AND offset? โ
โ โ Offset date-time (absolute instant) โ
โ 1979-05-27T07:32:00Z โ
โ โ
โ Has date AND time, NO offset? โ
โ โ Local date-time (wall clock) โ
โ 1979-05-27T07:32:00 โ
โ โ
โ Has date ONLY? โ
โ โ Local date โ
โ 1979-05-27 โ
โ โ
โ Has time ONLY? โ
โ โ Local time โ
โ 07:32:00 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Integer Prefixes
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ INTEGER FORMATS โ
โ โ
โ Decimal: 42 -17 +99 โ
โ Hex: 0xDEADBEEF (0x prefix) โ
โ Octal: 0o755 (0o prefix) โ
โ Binary: 0b11010110 (0b prefix) โ
โ โ
โ Leading zero in decimal: INVALID โ
โ 0644 โ error โ
โ 0o644 โ octal โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
String Escapes
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ BASIC STRING ESCAPES โ
โ โ
โ \n newline \t tab โ
โ \" quote \\ backslash โ
โ \u00E9 รฉ \U0001F600 ๐ โ
โ โ
โ LITERAL STRINGS: no escapes โ
โ 'C:\Users' โ C:\Users (backslash preserved) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Summary
| Item | Value |
|---|---|
| String forms | Basic, multi-line basic, literal, multi-line literal |
| Basic string escapes | \n, \t, \", \\, \uXXXX, \UXXXXXXXX |
| Integer prefixes | 0x hex, 0o octal, 0b binary |
| Leading zero | Forbidden in decimal integers |
| Float requirement | Decimal point or exponent |
| Special floats | inf, -inf, nan |
| Booleans | true, false (lowercase) |
| Date/time types | Offset, local date-time, local date, local time |
| RFC standard | RFC 3339 |
Key takeaways:
- TOML types are syntax-determined. A quoted value is a string; a bare number is a number. There is no resolver guessing whether
NOis a boolean or a string, which is the format’s core advantage over YAML. - Four string forms serve different needs. Basic for escapes and Unicode, literal for paths and regex, multi-line variants for text blocks. The literal form exists because backslash-heavy strings are unreadable when escaped .
- Integers have four bases and no leading zeros.
0x,0o, and0bprefixes are explicit;0644is an error, not octal . - Floats require a decimal point or exponent.
42is an integer;42.0and4e1are floats. Special valuesinfandnanare lowercase. - Date/time has four types, not one. Offset date-times are absolute; local forms are wall-clock values without timezone. The distinction is encoded in the syntax and preserved by parsers .
Remember: TOML’s type system is small because configuration files need few types. Strings, numbers, booleans, and dates cover almost everything a build tool or application reads. The failures come from the edges: a leading zero in an integer, a backslash in a basic string, a local date-time mistaken for an absolute instant. When a value fails to parse, check the syntax first: is it quoted when it should be bare, or bare when it should be quoted? Is the boolean lowercase? Does the date have an offset if the instant matters? The type is in the syntax, and the syntax is the answer.
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!