TOML Formatter

Formatters

How to use the TOML Formatter

Format your TOML in three steps:

1

Paste your TOML

Paste TOML with inconsistent spacing or formatting into the input box. Load a sample to see the expected input format, or upload a .toml file directly.

2

Click Format TOML

Press Format TOML. The formatter normalises key = value spacing, reformats inline tables ({key = val}), cleans up inline arrays, and ensures consistent blank lines between sections.

3

Copy or download

Click Copy to send the formatted TOML to your clipboard, or Download to save it as a .toml file for your project.


When to use this tool

Use the TOML formatter to clean up TOML configuration files:

  • Standardising Cargo.toml files after manually adding or editing Rust dependencies
  • Formatting pyproject.toml files shared between team members with different editors
  • Cleaning up TOML config files that were generated by tools with inconsistent spacing
  • Normalising inline tables and arrays in Taplo-managed configuration files
  • Reformatting application config TOML files before committing to version control
  • Fixing key=value entries that are missing required spaces around the equals sign
  • Ensuring consistent blank lines between TOML sections for readable diffs in pull requests

Frequently asked questions

Q:Does the TOML formatter validate TOML syntax?
The formatter normalises TOML using pattern-based processing rather than a full TOML parser. Well-formed TOML is reformatted correctly; for strict spec-level validation (type coercion, duplicate keys, date formats), run the output through a dedicated TOML validator or use Taplo's language server in your editor.
Q:Will it handle nested inline tables like {key = {nested = value}}?
The formatter handles one level of inline table nesting. Deeply nested inline tables are preserved but may not be reformatted with inner spacing. The TOML specification discourages deeply nested inline tables — consider converting them to standard table sections for readability.
Q:Does it support TOML datetime values?
TOML datetime values (e.g. 2024-01-15T10:30:00Z) are treated as regular values and preserved exactly as written. The formatter does not parse or validate datetime format — it only adjusts whitespace around the key = value structure.
Q:Will formatting change the meaning of my TOML?
No — the formatter only adjusts whitespace (spaces around = signs, blank lines between sections, inline spacing) and never alters key names, values, section names, or the document structure. The formatted TOML is semantically equivalent to the original.
Q:How should I format Cargo.toml dependency tables correctly?
Dependencies can be written as simple version strings (react = '1.0') or inline tables (serde = { version = '1.0', features = ['derive'] }). The formatter normalises both forms — simple strings are preserved and inline tables get consistent key = value spacing inside the braces. Multiline table sections ([dependencies]) are formatted with one blank line before each section header.
Q:What is TOML and why is consistent formatting important?
TOML (Tom's Obvious Minimal Language) is a configuration file format used by Rust (Cargo.toml), Python packaging (pyproject.toml), Hugo, Gitea, and many modern tools. Unlike JSON, TOML is hand-edited frequently, so consistent spacing and section layout make diffs cleaner, review easier, and accidental whitespace-only changes less likely to pollute pull requests.