TOML Formatter
Validate and cleanly format TOML configuration files.
Make a TOML file easier to read
TOML is the format behind Cargo.toml, pyproject.toml and many other project files. It is friendly to write, but hand-edited files often end up with uneven spacing and tables crammed together. This formatter restyles the text so that each table header stands out, values line up with a consistent equals sign, and blank space appears where it helps.
Formatting a file
- Paste your TOML into the Input Data box, or press Sample to load a short server and database example.
- Click Process / Generate.
- Review the coloured output: table headers in bold blue, keys in pink, values in green and comment lines in grey italics.
- Press Copy to take the result or Download to save it as result.txt. Clear wipes the input.
What the formatter does line by line
- Every line is trimmed, so leading and trailing spaces disappear and blank lines are dropped.
- A line starting with a square bracket is treated as a table header. A blank line is inserted before every header after the first.
- A line containing an equals sign is split at the first one and rewritten as key = value.
- Lines beginning with # are shown as comments, and any other line is passed through unchanged.
When it comes in handy
- Cleaning up a Cargo.toml dependency section before committing.
- Making a configuration example look consistent in a README.
- Reading a dense config someone pasted with no blank lines between tables.
- Normalising quick edits such as user=root into user = root.
What it does not do
The tool does not parse TOML, so it will not tell you that a string is unclosed or that a key is defined twice, even though the summary always reports that formatting succeeded. Because every line is trimmed independently, indentation inside multi-line arrays and multi-line strings is lost, and a triple-quoted string that spans lines is printed as separate lines. A comment line that happens to contain an equals sign will be treated as a key and value pair. Removing all blank lines also means any spacing you added within a table is not kept. For files that rely on multi-line values, compare the result with your original before replacing it. The processing happens in the browser page.
Related Tools
Related Tools