Skip to content

Menu

TOML Formatter

Format and validate TOML files

Runs entirely in your browserFormattersFree, no sign-up
Loading tool

01What is TOML Formatter?

TOML files start neat and drift. Someone pastes a block from docs with stray indentation, a teammate adds keys without spaces around the equals sign, and the [dependencies] list becomes hard to scan. This formatter tidies a TOML file and tells you when it isn't valid at all. The first step is a real parse. Your text goes through a full TOML 1.0 parser, written against the rules at toml.io. If the file breaks the spec, you see the first problem and its line number instead of formatted output. Typical catches are a duplicate key, a [table] defined twice, an unterminated string, a leading zero on a number and a missing value. Once the file parses, formatting runs line by line. Leading indentation is stripped. A blank line goes in front of every [section] header and runs of blank lines collapse to one. Comments stay where they were. Inside each group of consecutive key = value lines, keys are padded so the equals signs line up. Values are never rewritten. An inline table such as tokio = { version = "1", features = ["full"] } keeps its exact spacing. Lines inside multi-line strings and multi-line arrays are copied untouched, because trimming them would change your data. Here's what that looks like. Paste name="app", an indented version="1.0.0", then [server] with host="localhost" and an indented port=3000. You get name padded to line up with version, a blank line, the [server] header, and host and port aligned underneath. There is a final safety check we like. The formatted text is parsed again and compared with the original data. If the two differ, you see your input unchanged with a warning, rather than a quietly altered config. A few limits. Only the first error is shown, so fix it and look again. Spacing inside values, like [ 80,443 ], is left as you wrote it. Key order is never changed. The parsing and formatting happen in this browser tab, so a Cargo.toml with private registry URLs stays on your machine.

Rust and Python developers who hand-edit Cargo.toml or pyproject.toml and want aligned, valid config before they commit. The tool runs entirely in your browser, so your data never leaves your device.

02How to use TOML Formatter

  1. Paste your file into Input TOML, or load the Config, Server or Messy example.
  2. If a red Line N message appears, fix that line. Output only shows once the TOML is valid.
  3. Read the result in Formatted Output, or click Format to refresh it.
  4. Click Copy to grab the formatted text. The reset button reloads the first example.

03Worked examples

Input: name="app" version="1.0.0" [server] host="localhost" port=3000
Result: name = "app" version = "1.0.0" [server] host = "localhost" port = 3000
Indentation is removed, a blank line is added before each table, and = signs line up within a block.
Input: ports=[ 80,443 ] [db] user = "x" # comment
Result: ports = [ 80,443 ] [db] user = "x" # comment
Spacing inside array values and trailing comments are left as written; only the key = value layout changes.
Input: a = 1 a = 2
Result: Line 2: duplicate key "a"
The input is parsed as full TOML first, so invalid files get an error instead of formatted output.
Input: key = "unterminated
Result: Line 1: unterminated string
Input: [server] port = 1 [server] host = "x"
Result: Line 4: table [server] is defined twice
TOML 1.0 forbids defining the same table twice. Put both keys under one [server] header.
Input: [dependencies] serde="1.0" tokio = { version = "1", features = ["full"] } anyhow="1"
Result: [dependencies] serde = "1.0" tokio = { version = "1", features = ["full"] } anyhow = "1"
Keys are padded to the longest key in the block. The inline table value is kept exactly as written.

04Common use cases

  • Aligning a long [dependencies] block in a Rust project's Cargo.toml before a code review
  • Cleaning up a pyproject.toml after several people added settings for Black, Ruff and pytest
  • Normalising a Hugo or Netlify config pasted from docs with mixed indentation
  • Finding the duplicated key or twice-defined [server] table that stops a hand-edited config from loading
  • Checking a TOML snippet from a README is valid before you commit it
  • Tidying a config generated by a script that wrote key=value with no spaces

05Tips

  • Array-of-tables headers like [[bin]] are meant to repeat and pass. A plain [table] defined twice is an error.
  • Only the first syntax error is reported. After fixing it, check whether a second one shows up.
  • Alignment makes diffs noisier when a long key is added later. Some teams skip it, so agree on a style per repo.
  • Values are copied as written, so big integers and float formats like 1e6 never get rounded or reformatted.
  • Alignment resets at each blank line or comment. Split long blocks with a blank line if one long key pushes everything too far right.

06Related concepts

TOML, Cargo.toml, pyproject.toml, Code formatting, Configuration files.

Frequently Asked Questions

What is TOML Formatter?

TOML Formatter is a free, browser-based developer tool on AIDToolStack. Format and validate TOML files It requires no installation or sign-up and works entirely in your browser.

Is TOML Formatter free to use?

Yes. No sign-up, no fees and no usage cap.

Does TOML Formatter store my data?

No. It runs in your browser; nothing is uploaded.

Cheat sheet

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…

What changed in AI dev tools, once a month

Renames, shutdowns, pricing changes and new MCP setups, each with a source.

Subscribe