Back to Tools

TOML Formatter

Validate and cleanly format TOML configuration files.

Input Data

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

  1. Paste your TOML into the Input Data box, or press Sample to load a short server and database example.
  2. Click Process / Generate.
  3. Review the coloured output: table headers in bold blue, keys in pink, values in green and comment lines in grey italics.
  4. 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


Frequently Asked Questions

Does the TOML Formatter validate syntax?
No. It does not parse the file, so errors such as unclosed strings, duplicate keys or invalid dates are not reported. The summary line only confirms the text was restyled. Use a TOML-aware parser or your language's tooling to validate.
How are tables separated in the output?
Each line starting with a square bracket is styled as a header, and the formatter inserts a blank line before every header except the first. Blank lines that existed inside a table are removed, so tables are separated but their contents are compact.
Will multi-line arrays and strings survive?
They may lose formatting. Each line is trimmed on its own, so indentation inside a multi-line array is stripped and a multi-line string is printed line by line. Check these sections manually before saving the result over your original.
What happens to comments?
Lines starting with # are shown in grey italics and kept in order. However, a comment that contains an equals sign is handled as a key and value pair, and inline comments after a value stay attached to that value.
Can I download the result?
Yes. Use Copy to send the text to your clipboard or Download to save it as result.txt. Rename it to the right filename, such as Cargo.toml, when you are ready to use it in a project.
Support Chat
We typically reply within minutes

Hello! 👋 Before we start, please tell us your name.