Overview
Introduction
TOML config files hand-edited over time often end up with inconsistent spacing and quoting.
This tool parses your TOML and re-serializes it, producing a normalized document, entirely in your browser.
What Is TOML Formatter?
A TOML formatter that parses input into structured data and re-serializes it with consistent formatting, the same parse-then-print approach a JSON formatter uses.
Comments are not preserved, since TOML's data model doesn't carry them through a parse round-trip.
How TOML Formatter Works
The document is parsed into a table structure, then re-serialized with normalized key and value formatting.
A malformed document (a missing quote, for example) fails to parse and reports the exact line and column.
When To Use TOML Formatter
Use it when cleaning up a hand-edited config file so key/value spacing and quoting are consistent.
It's also a fast way to verify that a TOML document is syntactically valid before using it in a build or CI pipeline.
Often used alongside JSON Formatter & Beautifier and YAML Formatter & Prettifier.
Features
Advantages
- Runs entirely client-side.
- Round-trips through a real parser, so output is guaranteed valid TOML if the input was valid.
- Supports the full TOML spec, including dates/times and inline tables, via a dedicated spec-compliant parser.
Limitations
- Comments in the original document are not preserved, since they aren't part of TOML's parsed data model.
Examples
Best Practices & Notes
Best Practices
- Format config files before committing them so diffs reflect real value changes.
- Keep a copy of a heavily commented config file before formatting it, since comments don't survive the round-trip.
Developer Notes
Uses `smol-toml`'s `parse()`/`stringify()` pair, a lightweight, spec-compliant TOML implementation with no native dependencies.
TOML Formatter Use Cases
- Cleaning up a hand-edited Cargo.toml or pyproject.toml snippet
- Validating a TOML document parses before using it in a build
- Checking that a TOML snippet from documentation is syntactically valid before adding it to a project
Common Mistakes
- Expecting comments to survive formatting; they're dropped because TOML's parsed data model doesn't retain them.
- Relying on this tool to validate against a schema; it only confirms the document parses as valid TOML, not that specific keys or types are present.
Tips
- If you need to keep comments, edit the file directly instead of round-tripping it through this tool.
- Use the reported line and column from a failed parse to jump straight to the problem in a hand-edited config file.