Skip to content

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.

🔒 Runs entirely in your browsertomlformatvalidateconfig
Output
Inline tables
Array wrap width

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_000 into 1000, or 0xff into 255, 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

  1. Paste the file

    A `Cargo.toml`, a `pyproject.toml`, a `netlify.toml`. Inconsistent spacing is the point — that is what is being fixed.

  2. 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.

  3. 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

Next

These accept what this tool produces, so the result can go straight in.