TOML Formatter & Validator
Formats and validates TOML, normalising table ordering and inline-table style.
Normalises the spacing in a TOML file — `key = value`, header whitespace, array wrapping — and checks it against the TOML 1.0 specification while it is there. Two readers run over the file: one that knows the spelling rules and keeps the comments, and one that knows the semantic ones and produces the JSON view.
TOML in
Drop a .toml file
Read in this tab only. Nothing is uploaded.
Formatted TOML
Formatted.
Tables
5
Key/value pairs
13
Comments
1
Check
passed
What it changes and what it leaves
- · The spacing around
key = value, the whitespace in a header like[ a . b ]and the gaps inside arrays and inline tables are normalised, with one blank line before each header. - · A short array goes on one line; an array past the wrap width, or one with a comment inside it, gets one element per line with a trailing comma.
- · Strings, numbers and dates are left exactly as written. Turning
1_000into1000, or0xffinto255, is an edit rather than a format. - · A key that does not need its quotes (
"name") loses them; a key that does ("127.0.0.1") is written with literal quotes. - · A leading zero, a misplaced underscore,
True, an inline table spread over several lines, a duplicate key and a table defined twice are all rejected, per the TOML 1.0 specification at toml.io.
To convert to JSON or YAML, use the JSON ⇄ TOML converter.
How to use it
Paste the file
A `Cargo.toml`, a `pyproject.toml`, a `netlify.toml`. Inconsistent spacing is the point — that is what is being fixed.
Set the array wrap width
A short array stays on one line; anything past the width, or with a comment inside it, gets one element per line with a trailing comma. That trailing comma is what keeps future diffs to one line.
Sort if that helps, and only then
Key sorting moves only the key/value lines and leaves comments and blank lines in place. Table sorting orders headers at one level and carries their sub-tables along. Array-of-table order is data, so it is never touched.
Common questions
Why is `1_000` not rewritten as `1000`?
Because that is an edit, not a format. Underscores in numbers, hexadecimal literals and the exact spelling of a date are all things the author chose. The formatter changes whitespace and quoting, and leaves the values as written.
It rejected my file but another parser accepted it.
Likely one of the things TOML 1.0 forbids and lenient readers allow: a leading zero, a misplaced underscore, `True` with a capital T, an inline table spread over several lines, a duplicate key, or a table defined twice. The error names which, with a line number.
What happens to a date when I switch to JSON?
It becomes a string, and a warning says so. TOML has offset date-times, local dates and local times as real types; JSON has none of them, so the text is carried across and its type is lost.
Are comments kept?
Yes, including their position relative to the key they belong to, which is the reason the formatter has its own scanner rather than reusing the converter’s reader. The comment count is shown in the stats.
Feed it from
JSON ⇄ TOML
Converts between JSON and TOML, mapping nested objects onto table headers.
JSON Formatter & Validator
Pretty-prints, minifies and validates JSON, pointing at the exact line and column of a syntax error.
YAML Formatter & Validator
Re-indents YAML consistently, validates it, and flags the tab and anchor mistakes that break parsers.
XML Formatter & Validator
Indents XML and reports the line and column of the first well-formedness fault.
Next
These accept what this tool produces, so the result can go straight in.
JSON Formatter & Validator
Pretty-prints, minifies and validates JSON, pointing at the exact line and column of a syntax error.
JSON ⇄ TOML
Converts between JSON and TOML, mapping nested objects onto table headers.
YAML Formatter & Validator
Re-indents YAML consistently, validates it, and flags the tab and anchor mistakes that break parsers.
Base64 Encoder & Decoder
Encodes and decodes Base64 and Base64URL for text or files, handling UTF-8 correctly.
curl to Code
Converts a curl command into fetch, axios, Python requests, Go, PHP or PowerShell.
Text Hash
Computes MD5, SHA-1, SHA-256, SHA-384, SHA-512 and CRC-32 of a string, with an uppercase and Base64 output option.