TOML Formatter

Format and validate TOML config files.

Runs locallyYour input is processed in this tab. The editor blocks outgoing network requests.
TOML input

The TOML Formatter validates and tidies TOML files such as Cargo.toml, pyproject.toml and application configs. It normalizes spacing around =, inside inline tables and arrays, and between tables, keeps your comments, and reports syntax errors with the exact line and column. Everything runs in your browser — nothing is uploaded.

How to format and validate TOML

  1. Paste TOML, drop a .toml file, or load the Cargo.toml example.
  2. Choose Format to tidy the file, or Validate to check it and see "Valid TOML — no syntax errors found." Both modes parse the whole document with a TOML 1.0 parser before changing anything.
  3. Copy or download the result with ⌘/Ctrl S, or use Convert to JSON to open the same document in TOML to JSON.

Examples

A cramped Cargo.toml

Spacing is normalized around =, commas and braces, and a blank line is added before each table header:

TOML
[package]
name="formattr"
version = "1.0.0"
authors=["Sam"]
[dependencies]
serde={version="1.0",features=["derive"]}
[[bin]]
name="fmt"
path="src/main.rs"

Result:

TOML
[package]
name = "formattr"
version = "1.0.0"
authors = ["Sam"]

[dependencies]
serde = { version = "1.0", features = ["derive"] }

[[bin]]
name = "fmt"
path = "src/main.rs"

A table defined twice

TOML forbids defining the same table or key twice, which often happens when two people edit a long config:

TOML
[server]
host = "0.0.0.0"
port = 8080
[server]
timeout = 30

Result:

Text
Invalid TOML document: trying to redefine an already defined table or value (line 4, column 2)
Hint: The same key or table is defined twice.

A bare string

Strings must be quoted, even when they contain no spaces:

TOML
name = formattr

Result:

Text
Invalid TOML document: invalid value (line 1, column 8)

Options explained

  • Sort keys — rebuilds the document from its parsed data with keys and tables in alphabetical order at every level. Because the file is regenerated rather than tidied line by line, comments are removed, and when the file had any, the notice "Sorting keys rebuilds the file, so comments were removed." says so; leave it off to keep comments and your own ordering.

The Format and Validate modes produce the same tidied output; Validate adds a confirmation notice, which is useful in a review when you only need to know whether a file parses.

Common TOML errors

"trying to redefine an already defined table or value"

The same key appears twice in one table, or a [table] header is repeated. Merge the two blocks into one. For a list of tables — several [[bin]] or [[servers]] entries — use double brackets, which are allowed to repeat.

"invalid value"

A value is not a valid TOML type. The usual cause is an unquoted string such as name = formattr. Wrap it in double quotes. Booleans must be lowercase: True is rejected, true is not. An unquoted word that happens to start like a number keyword — info begins with inf — produces "each key-value declaration must be followed by an end-of-line" instead, with the hint "Each key = value pair must be on its own line. Strings must be quoted: level = "info"."; the fix is the same.

"illegal character in key"

Bare keys may contain only letters, digits, underscores and hyphens. A key like my key or café must be quoted: "my key" = 1.

"illegal character in numeric literal" on a date

TOML dates need zero-padded parts: 2026-09-26, not 2026-9-26. Times use 07:30:00, and full timestamps use 2026-09-26T09:00:00Z or an offset like +05:30.

A large integer looks different elsewhere

TOML integers are 64-bit, and the formatter keeps every digit, so id = 9007199254740993 is never rounded here. Tools that read TOML into double-precision numbers may still round values above 2^53, so store IDs that large as strings if other programs read the file.

"The file uses syntax the tidier does not handle"

Formatting is done line by line to keep comments. If the tidied text would not parse again — rare, usually around unusual multi-line strings — the original is returned unchanged with that notice. The file itself is valid.

FAQ

How do I validate a Cargo.toml or pyproject.toml file?

Paste the file here and choose Validate. The whole file is parsed as TOML 1.0; if it parses, you see "Valid TOML — no syntax errors found", otherwise the first error with its line and column. This checks syntax only — it does not check whether Cargo or your Python build backend recognizes each key.

Does formatting keep my comments?

Yes, in the default mode. Comment lines and trailing comments stay where they are, and only spacing changes. Comments are dropped only when Sort keys is on, because sorting rebuilds the file from its data, and TOML parsers do not keep comments in that data; a notice tells you when that happened.

What is the difference between [table] and [[table]]?

Single brackets define one table and may appear only once for a given name. Double brackets define an array of tables: each [[bin]] header starts a new entry in the bin list. In JSON, [package] becomes an object and repeated [[bin]] headers become an array of objects.

What is the difference between TOML, YAML and JSON?

TOML is designed for configuration: explicit types, required quotes on strings, and no indentation rules. YAML is more compact but indentation-sensitive and has surprising implicit types. JSON has no comments. Rust, Python packaging and many CLI tools chose TOML because it is hard to get subtly wrong. For YAML files, use the YAML Formatter.

Is it safe to paste a config file with secrets?

The formatter runs entirely in your browser, in an isolated frame that blocks network requests, so the file is never uploaded. Settings are remembered on this device; the file content is not stored unless you turn on "Remember my last input".

Convert a finished file with TOML to JSON, or go the other way with JSON to TOML. Other config and data formats are under Data.

Browse all Data Formatters & Converters