T tomlkit·org
Inspect Formatter Validator Convert TOMLJSON JSONTOML TOMLYAML YAMLTOML INITOML TOMLINI .envTOML TOML.env TOMLTS Transform Sort keys Flatten Minify Compare Diff Merge

TOML Sorter

updated 24 May 2026

Sort every table's keys alphabetically and re-emit canonical TOML. Use it to make diffs reproducible, to find a key quickly in a long file, or to enforce a house style. Comments are dropped.

canonical TOML 1.0 output

Why sort keys

TOML doesn't care about key order within a table, but humans and version control systems do. Sorting alphabetically gives you:

  • Reproducible diffs. Two contributors editing the same file in different orders produce identical output.
  • Quick lookup. Finding a setting in a 500-line config becomes a binary-search problem.
  • House-style enforcement. Pair this with a pre-commit hook to keep configs tidy.

How to use it

  1. Paste TOML on the left, click Sort.
  2. Every table — including nested and arrays-of-tables — has its keys re-emitted alphabetically.
  3. Copy or download the result.

Notes

  • Comments are stripped. Re-emission goes through the parsed value tree, which doesn't carry comments.
  • Array values keep their order. Only object/table keys are reordered.
  • The output is canonical TOML 1.0. Quoting and spacing get normalized as a side effect.

FAQ

Will it move [package] before [dependencies]?

Yes — top-level table headers are sorted alongside everything else. If you depend on a specific section order for documentation, sort selectively rather than globally.

Does case matter?

Yes. Uppercase letters sort before lowercase in ASCII order. Keep your casing consistent for predictable results.