TOML Formatter
Formatters & BeautifiersFormat TOML config files — Cargo.toml, pyproject.toml, Hugo configs. Free, private — all processing in your browser.
Paste messy TOML and get it tidied up: consistent spacing around the equals sign, a blank line before each table header, trailing whitespace stripped, and extra blank lines collapsed. It turns hand-edited config that's drifted out of shape — title="x" here, name = "y" there — into something clean and consistent.
TOML (Tom's Obvious, Minimal Language) is the config format behind Rust's Cargo.toml, Python's pyproject.toml, and a lot of other tooling. It's designed to be easy to read and write by hand, which means it's also easy to leave inconsistent: mixed spacing, no separation between sections, stray blank lines. This tool cleans that up without changing what the config means.
Click Format to run it, or Load sample to see it work on a typical config with tables, arrays, and inline values. It's a tidier, not a validator — see the notes for what it does and doesn't touch.
How to use the TOML Formatter
- 1
Paste TOML
Cargo.toml, pyproject.toml, Hugo config, any TOML file.
- 2
Configure options
Align =? Sort sections? Short vs long arrays? Defaults work for most cases.
- 3
Click Format
Cleanly formatted TOML with preserved comments.
- 4
Copy or download
Apply to your project. Cargo.toml is ready for cargo build.
Worked examples
Cargo.toml
Rust package manifest.
[package]
name="my-crate"
version="0.1.0"
[dependencies]
serde="1.0"
tokio={version="1",features=["full"]}[package]
name = "my-crate"
version = "0.1.0"
[dependencies]
serde = "1.0"
tokio = { version = "1", features = ["full"] }pyproject.toml
Python package config.
[project] name="my-pkg" version="0.1.0" dependencies=["requests>=2.0","click>=8.0"]
[project]
name = "my-pkg"
version = "0.1.0"
dependencies = [
"requests>=2.0",
"click>=8.0",
]Array of tables
Multiple servers.
[[servers]] name="web-1" ip="10.0.0.1" [[servers]] name="web-2" ip="10.0.0.2"
[[servers]] name = "web-1" ip = "10.0.0.1" [[servers]] name = "web-2" ip = "10.0.0.2"
Multi-line string
Description with newlines.
description=""" A multi-line description. """
description = """ A multi-line description. """
Nested tables
Subsections.
[server.ssl] cert="/path/cert" key="/path/key" [server.log] level="info"
[server.ssl] cert = "/path/cert" key = "/path/key" [server.log] level = "info"
Features at a glance
TOML 1.0 support
All v1.0 syntax: strings (basic, literal, multi-line), numbers (hex, octal, binary), dates, arrays, tables, inline tables, arrays of tables.
Section organization
Detects tables and sub-tables. Optional: sort sections alphabetically.
Alignment
Optional: align `=` in consecutive key-value pairs for readability.
Preserves comments
# comments kept in original positions — important for documented configs.
Syntax validation
Parses TOML to check well-formedness. Reports errors with line numbers.
Consistent string style
Normalizes quotes (single to double where safe). Multi-line strings preserved.
Array formatting
Short arrays on one line. Long arrays broken onto multiple lines.
100% client-side
Your config (possibly with secrets, internal URLs) stays in browser.
Common use cases for the TOML Formatter
Rust
- →Cargo.toml formatting: Rust package manifest. Format dependencies, features, targets.
- →Cargo.lock inspection: Lockfile in TOML format (generated, do not manually edit).
Python
- →pyproject.toml: PEP 621 package metadata. Standard for all modern Python packaging (Poetry, Hatch, pip).
- →Poetry configs: Poetry-specific extensions in pyproject.toml — tool.poetry sections.
- →Black, Ruff, mypy configs: Tool configuration in [tool.*] sections of pyproject.toml.
Static sites
- →Hugo config.toml: Hugo static site generator — TOML is preferred format.
- →Netlify.toml: Netlify deployment config — build settings, redirects, functions.
- →Zola config: Another static site generator using TOML.
Other tools
- →dbt profiles: Data transformation tool uses TOML for profiles.
- →Gleam / Elixir / Go tools: Various language tools adopting TOML.
- →Custom app configs: Many custom tools use TOML for human-editable configs.
Under the hood
Formatting is line-based, which suits TOML because TOML ignores indentation entirely — nesting is expressed through [table] and [[array-of-tables]] headers, not whitespace. For each key/value line it finds the top-level equals sign (skipping any = that sits inside a quoted key), then rewrites the line as key = value with exactly one space on each side. It puts a single blank line before every table header, strips trailing whitespace, and collapses runs of three or more blank lines down to one.
Crucially, it tracks state so it doesn't corrupt multi-line constructs. When a value opens a multi-line array ([ that isn't closed on the same line) or a multi-line basic/literal string (""" or '''), the following lines are passed through untouched until the construct closes. That means an = sign inside a multi-line string won't be mistaken for a key/value separator, and a formatted array keeps your chosen layout.
It's a formatter, not a parser or validator — it won't flag TOML syntax errors, resolve dotted keys into nested tables, or reorder anything. Everything runs in your browser; nothing is uploaded.
Common problems and solutions
⚠It formats, it doesn't validate
Invalid TOML won't be flagged — the tidier just adjusts spacing and blank lines. If your config has a real syntax error, use a TOML parser to catch it; this tool assumes the input is already valid.
⚠Multi-line arrays keep your layout
By design, lines inside a multi-line array are passed through as-is rather than reflowed. Spacing inside those brackets isn't normalized, so a multi-line array looks exactly as you wrote it (minus trailing whitespace).
⚠Indentation is cosmetic in TOML
TOML doesn't use indentation for structure — [table] headers do. If you indent keys under a table for readability, that indentation is stripped on key/value lines, which is valid TOML and doesn't change meaning.
⚠Comments are preserved but not reformatted
Full-line comments are kept and trailing comments stay attached to their line. The tool won't align or restyle comments beyond trimming trailing whitespace.
⚠Dotted keys aren't expanded into tables
a.b.c = 1 stays as a dotted key; it isn't rewritten into [a.b] table form. The tool preserves your structure and ordering rather than reorganizing the document.
TOML Formatter — comparisons and alternatives
A real TOML library (like Rust's toml crate or Python's tomllib) parses your config into a data structure and can re-serialize it in a canonical form — that's more thorough but also reorders and rewrites more aggressively, and it rejects invalid input outright. This tool takes a lighter touch: it tidies spacing and spacing between sections while leaving your structure and ordering exactly as written, which is what you usually want when cleaning up a file you'll keep editing by hand.
Use a full parser when you need validation or guaranteed-canonical output for a build pipeline. Use this for a quick visual cleanup of a config file before committing it. If you need to convert between formats, a JSON-to-YAML or dedicated converter is the right tool — this only formats TOML, it doesn't convert it.
Frequently asked questions about the TOML Formatter
▶What does this tool actually change?
It normalizes spacing around = to 'key = value', adds one blank line before each table header, trims trailing whitespace, and collapses excess blank lines. It leaves your keys, values, ordering, and comments intact.
▶Will it break my multi-line arrays or strings?
No. It detects multi-line arrays and multi-line strings (""" or ''') and passes their inner lines through unchanged, so an = inside a string isn't misread and your array layout is preserved.
▶Does it validate my TOML?
No. It's a formatter, not a parser. It won't report syntax errors or check that your document is valid TOML. For validation, run the file through a real TOML library like Python's tomllib or Rust's toml crate.
▶Why did the indentation under my table disappear?
Because TOML ignores indentation — structure comes from [table] headers, not whitespace. Removing leading spaces on key/value lines produces standard TOML and doesn't change what the config means.
▶What is TOML used for?
It's a human-friendly config format used by Rust (Cargo.toml), Python packaging (pyproject.toml), and many other tools. It aims to be obvious to read and write by hand, mapping cleanly to a hash table of key/value pairs and tables.
Additional resources
- TOML v1.0 Specification — Official TOML specification.
- Cargo.toml Reference — Rust Cargo manifest format.
- PEP 621 — pyproject.toml — Python package metadata standard.
- Hugo Configuration — Hugo static site TOML config.
- Netlify.toml Reference — Netlify build/deploy config.
Related tools
All Formatters & BeautifiersGit Commit Message Generator
Create conventional commit messages — feat, fix, docs, with scope and breaking changes
.gitignore Generator
Create .gitignore files for 100+ languages, OS, IDEs — combinable templates
HTML Formatter
Format, indent, and beautify HTML, XHTML, and HTML5 markup
JSON Formatter
Format, validate, and beautify JSON instantly in your browser
JSON to YAML Converter
Convert JSON to YAML or YAML to JSON — preserves structure, nested objects
Python Formatter
Format Python code with Black-compatible style — PEP 8 compliant, consistent
Learn more
Explore more tools
200+ free tools that run in your browser.
Browse all tools →