Skip to content

TOML Formatter

Tidy a TOML file: consistent quoting, ordered tables, keys before headers.

Plain keys are always written above the first table header, because TOML would otherwise read them as part of that table. Comments are not preserved.

Quick Tool Overview

The TOML Formatter re-emits a file from its parsed form: plain keys written above the first table header where TOML requires them, tables as [a.b], arrays of tables as [[a]], and quoting made consistent.

What it does
Tidies and validates a TOML document
You give it
Any TOML file
You get back
Correctly ordered, consistently quoted TOML
Best for
Cargo.toml, pyproject.toml and site config files
Developer Tools Free, unlimited use No sign-up Runs in your browser

About the TOML Formatter

TOML has one rule that catches everyone: every plain key must be written before the first table header, or it silently belongs to that table instead of the document. The formatter re-emits the file in the correct order, so that bug cannot survive a pass through it.

Beyond the ordering it normalises the rest: strings quoted consistently, bare keys left bare and awkward ones quoted, nested tables written as proper [a.b] headers, and arrays of tables as [[a]]. The file is parsed first, so a document that does not format is a document that does not parse, and you get the line number rather than a vague complaint.

Key features of the TOML Formatter

Fixes the scoping trap

A top-level key written below a [table] header belongs to that table. Re-emitting moves plain keys above the first header, where the author meant them.

Correct table syntax

Nested tables become dotted [a.b] headers and arrays of tables become [[a]] blocks, which is the only valid form for a list of records.

Consistent quoting

Bare keys stay bare, awkward ones are quoted, and string escapes are normalised.

Validation included

The file is parsed before it is written, so anything that will not format reports the line it failed on.

Dates kept as written

TOML has real date and time types, so they are preserved in their original form rather than reinterpreted.

How to use the TOML Formatter

  1. 1

    Paste your TOML

    A Cargo.toml, a pyproject.toml, a Netlify config or any TOML file.

  2. 2

    Read the verdict

    A parse failure names the line; a clean parse is reformatted straight away.

  3. 3

    Check the table order

    Plain keys are moved above the first table header, which is where TOML requires them.

  4. 4

    Copy the result

    The tidied file is ready to commit.

Frequently asked questions

Because TOML assigns every key after a [table] header to that table. A top-level key written below one is not top-level at all, which is almost never what the author meant.

Reviews of the TOML Formatter

What people who use the TOML Formatter think of it. Reviews come from visitors and are posted as written.

No ratings yet

Yours would be the first.

  • 5 0 reviews rated 5 stars
  • 4 0 reviews rated 4 stars
  • 3 0 reviews rated 3 stars
  • 2 0 reviews rated 2 stars
  • 1 0 reviews rated 1 star

Write a review

Used this tool? Your rating helps the next person decide.

Your rating

Plain text only — links, email addresses and HTML are not accepted. Your name and review are shown publicly; nothing else is collected. See the privacy policy.

0 reviews

Newest first

No reviews yet

Be the first to rate the TOML Formatter. It takes half a minute and no account.

Write the first review

More developer tools