Skip to main content
Toollyz

Search tools

Search for a command to run...

TOML Formatter

Beautify and validate TOML 1.0 configuration files (Cargo.toml, pyproject.toml, dprint config). Line-pointing error messages, alphabetical key sorting, multi-line array threshold and stats. 100% client-side.

What is the TOML Formatter?

TOML Formatter is a from-scratch TOML 1.0 parser + emitter built specifically for the subset that covers 95% of real-world config files (Cargo.toml, pyproject.toml, dprint config, hyperfine config, niri config, …). It handles comments, bare and quoted keys, dotted keys, basic / literal / multi-line strings (with escape sequences and `'''` literal blocks), decimal / hex / octal / binary integers with underscore separators, floats with inf / nan, booleans, inline arrays (multi-line, trailing-comma-tolerant), inline tables, standard tables, dotted tables, and array of tables (`[[…]]`). Parse errors are reported with both line and column numbers and a precise human-readable message — handy when a 600-line Cargo.toml fails. The emitter re-prints with consistent indentation, an optional alphabetical key sort and a configurable threshold for breaking inline arrays into multi-line. RFC 3339 datetimes are preserved verbatim (we don't try to re-format them). Pure functions, no network.

How to use it

  1. Paste your TOML — Cargo.toml, pyproject.toml, anything 1.0-compliant.
  2. Toggle 'sort keys alphabetically' or change the array-break threshold as you like.
  3. Read the line-pointing error message if the parse fails.
  4. Copy the formatted output or download as .toml.

Benefits

  • Supports the TOML 1.0 subset that covers 95% of real-world config files.
  • Standard, dotted, and array-of-tables (`[[…]]`) section headers all parse correctly.
  • Multi-line basic (`"""…"""`) and literal (`'''…'''`) strings with proper escape handling.
  • Integer literals in decimal, hex (`0x`), octal (`0o`) and binary (`0b`) with underscore separators.
  • Inline tables (`{ key = value, … }`) and multi-line arrays with trailing-comma tolerance.
  • Line + column error messages — find the typo in a 600-line Cargo.toml instantly.
  • Optional alphabetical key sort within each table.
  • Configurable threshold for breaking inline arrays into multi-line.
  • Runs 100% in your browser — Toollyz has no server.

Frequently asked questions

Does this support the full TOML 1.0 spec?

It supports the subset that covers 95% of real-world config files — standard tables, dotted keys, inline tables, all string forms, all integer/float forms, booleans, inline and multi-line arrays, and array-of-tables. Some edge cases (mixed-type arrays in spec-strict mode, locale-specific dates) may parse but not re-emit identically.

Will it work on Cargo.toml?

Yes — Cargo.toml is one of our main test cases. Dependencies, features, workspace members, build profiles all round-trip cleanly.

What about pyproject.toml?

Yes. `[tool.poetry]`, `[build-system]`, `[project]`, `[tool.ruff.lint]` and friends all parse and re-emit.

Can it convert TOML to JSON?

Not in this version — the focus is formatting and validation. If you need TOML → JSON, paste the formatted TOML into a server-side converter; the predictable formatting makes that easier.

How does it handle multi-line arrays?

Inline by default. When the array has ≥ the 'Array break at' threshold items (default 4), we break each onto its own line for readability. Tune the threshold to taste.

Will key sort break my Cargo.toml?

Cargo doesn't care about key order — it's safe to sort. But the alphabetical sort is OFF by default since some configs (eslint, prettier) read better with logical grouping intact.

What's a 'dotted key'?

TOML lets you write nested keys as `tool.poetry.dependencies = { … }` or split the same intent into nested tables. Dotted keys are parsed as nested tables — when you re-emit, you get the table form.

Does it handle multi-line strings correctly?

Yes — both basic (`"""`) and literal (`'''`) multi-line strings. The leading newline immediately after the opening delimiter is stripped per spec.

What about RFC 3339 datetimes?

Preserved verbatim. We detect them with a regex and pass them through as opaque strings — re-formatting dates would require timezone handling that's out of scope.

Is anything uploaded?

No. The whole parser and emitter run in your browser.

Will it warn me about duplicate keys?

TOML 1.0 says duplicate keys are an error. We currently overwrite silently — a future version will flag duplicates explicitly.