TOML Formatter
Canonical formatting for TOML. Paste your document and receive a normalized version with consistent spacing, string quoting, and table layout. Everything runs in your browser.
TOML Formatter
Before you start
You need one of the following:
- A TOML configuration file (like
Cargo.toml,pyproject.toml, or a customconfig.toml), or - TOML text you can copy and paste directly into the editor.
The most important thing to know is that this tool strips comments. It works by parsing your text into a data structure and then re-emitting it. If you have documented your config with # comments, they will not appear in the formatted output.
There is no file size limit, but because everything runs in your browser's memory, extremely large files (50 MB+) might cause the tab to hang. For standard development configs, it is effectively instant. I never see your data — processing happens entirely on your machine.
How to use it
- Paste your TOML into the left pane, or drop a
.tomlfile anywhere on the editor. - Click Format to clean up the syntax and spacing.
- Check the status bar at the bottom to ensure the document was parsed successfully.
- Click Copy result to put the canonical version on your clipboard.
Example
Input:
[database]
server="192.168.1.1"
ports=[ 8001,8002 ]
connection_max=5000
enabled = true
Output:
[database]
server = "192.168.1.1"
ports = [8001, 8002]
connection_max = 5000
enabled = true
The formatter normalizes spacing around the = operator and cleans up whitespace inside arrays, ensuring your file follows the standard TOML 1.0 aesthetic.
Tips & common pitfalls
- Comment loss is the big trade-off. Since this tool re-serializes the data, your
#comments are discarded. Use this for machine-generated TOML or for cleaning up files where comments aren't critical. - Strict validation. If your TOML is invalid (e.g., a missing quote or a duplicate key), the tool won't format it. It acts as a validator and formatter in one go.
- Consistent quoting. The tool will often standardize string quoting. If you have a mix of single and double quotes for basic strings, it will move them toward a consistent canonical style.
- Safe for secrets. Because no data is uploaded to a server, it's safe to use for local config files that contain API keys or environment variables.
Troubleshooting
The status bar shows an error and nothing happens.
This means your TOML has a syntax error. The parser cannot format a "broken" document. Check for unclosed brackets in arrays or missing double quotes around strings.
My # comments disappeared after formatting.
This is expected behavior. My parser reads the values into memory and writes them back out from scratch, which drops metadata like comments. I recommend keeping a backup if your comments are important.
Related tools
See also: if you need to do something adjacent on this site, try JSON to TOML to convert JSON to TOML, TOML to JSON to convert TOML to JSON, or TOML to YAML to convert TOML to YAML.
Frequently asked questions
Will formatting change the meaning of my config?
No. The tool parses the input into a logical tree and then re-emits it. The resulting document is semantically identical to your input — only the "white space" and visual layout change.
Does it handle TOML 1.0 features?
Yes. This uses a modern parser that supports the full TOML 1.0 specification, including dotted keys, varied date formats, and hex/octal/binary numbers.
Why are my keys in a different order?
While the tool tries to preserve the order found in your input, some complex nested structures might be emitted in a way that the parser finds "optimal." TOML itself doesn't care about key order within a table.
Is there a limit on file size?
There is no hard cap, but your browser is doing all the work. It handles Cargo.lock files with thousands of lines easily, but multi-megabyte files might be sluggish.
Does my data ever leave my computer?
Never. I built this to be 100% client-side. The code runs in your browser's JavaScript engine. You can even check your network tab to verify that no POST requests are sent when you click format.
Can I use this for pyproject.toml?
Yes, it's great for cleaning up pyproject.toml files, especially if they've been edited by multiple different tools or people. Just remember the caveat about comments!