TOML Formatter
100% LocalPrettify, minify, and validate TOML configuration files.
Privacy note
This tool runs entirely in your browser. Your input is never uploaded, logged, or sent to AllDevToolsHub or anyone else, and it keeps working offline once the page has loaded.
How to Use TOML Formatter
Paste TOML
Enter TOML content to format or validate.
Format
Click Format to apply standard TOML indentation and structure.
Copy
Copy the formatted TOML.
TOML Formatter: the essentials
The TOML Formatter cleans up **`Cargo.toml`, `pyproject.toml`, and other TOML config files**, consistent table spacing, key-value alignment, and **duplicate-key / syntax validation**. Includes minify mode for stripping comments and whitespace. Useful when you need to format without installing `taplo` or `tomli-fmt` locally.
Key points
- Reflows toml formatter into clean, readable output with standard indentation and keyword casing.
- Runs entirely in your browser, so production data never leaves your device.
- Supports multiple dialects and syntax variants for broad compatibility.
What is TOML Formatter?
Frequently Asked Questions
Technical Deep Dive
TOML Formatter
Format TOML config files (Cargo.toml, pyproject.toml) with proper section spacing and key-value alignment. Includes minification and basic validation with duplicate key detection and syntax warnings.
Reliable Formatting
Idempotent, spec-compliant output, run it twice, get the same result.
Configurable Style
Indentation, quote style, and edge-case handling tunable to your team's conventions.
Big Inputs, Fast
Handles megabytes of code without freezing the tab, heavy lifting runs in workers.
TOML: Configuration That Reads Like Configuration
TOML was created in 2013 by Tom Preston-Werner to be "a config format that humans don't hate and machines can parse without ambiguity." It avoids JSON's lack of comments, YAML's whitespace-sensitivity gotchas, and INI's lack of nesting. The result is a format that dominates Rust (Cargo.toml), modern Python packaging (pyproject.toml), and many Go projects. This formatter cleans up TOML files without needing to install a CLI tool.
Quick Tour of the Syntax
Key-value pairs
Strings double-quoted by default. Numbers, booleans, dates unquoted.
Tables
Each [name] starts a new table; all subsequent keys until the next [ header belong to it.
Nested tables (dotted)
Produces { servers: { alpha: {...}, beta: {...} } }.
Inline tables
Like JSON object. Single line. Good for short structures.
Arrays
Multi-line OK; trailing commas allowed.
Array of tables
[[name]] (double brackets) appends a table to an array.
Comments
# starts a comment; continues to end of line.
Strings
Numbers
Dates and times
RFC 3339 format. Native type, parsers return actual Date objects, not strings.
Common Real-World TOML
Cargo.toml (Rust)
pyproject.toml (Python, PEP 518/621)
.taplo.toml (TOML formatter config)
What `terraform fmt`'s TOML Equivalent (`taplo`) Does
taplo (the standard Rust-based TOML formatter):
- Indents consistently (2 spaces default).
- Aligns
=within a table if configured. - Wraps long inline tables to multi-line.
- Adds blank lines between top-level tables.
- Sorts keys (optional, per-table or globally, usually NOT default).
- Validates syntax and emits clear errors with line numbers.
This formatter applies similar rules in the browser.
Subtle TOML Rules
Tables can't be redefined
But you CAN add to existing tables via dotted headers:
Keys with dots in them
Quote keys when the literal name contains dots, spaces, or special characters.
Array of tables can't conflict with single table
Inline tables are immutable
For mutable / nested expansion, use header tables.
Whitespace and blank lines
Within a table: blank lines between assignments are allowed. Between tables: convention is one blank line.
Trailing commas
Allowed in arrays and inline tables (added in TOML 1.0).
Common Mistakes
Using YAML conventions in TOML
Right:
Forgetting quotes on strings
Boolean capitalization
Mixed types in array (TOML < 1.0)
Pre-TOML 1.0, arrays had to be homogeneous. TOML 1.0 allows heterogeneous arrays, but many older parsers reject them. Check your parser's TOML version.
Comments mid-value
OK in TOML 1.0.
Trailing whitespace in keys
TOML vs YAML vs JSON
| Feature | TOML | YAML | JSON |
|---|---|---|---|
| Comments | Yes (#) |
Yes (#) |
No |
| Type ambiguity | No (explicit types) | Yes (yes → bool surprise) |
No |
| Whitespace-significant | No | Yes | No |
| Multi-line strings | Yes (""") |
Yes (` | and>`) |
| Datetime native | Yes | Partial | No |
| Nesting | Tables (verbose at depth) | Indentation (compact) | Braces |
| Best for | Config | Config + data | Data exchange |
Rule of thumb: TOML for flat-ish config with explicit types; YAML for nested data (k8s manifests); JSON for machine-to-machine data exchange.
Tooling
Validators
taplo, Rust-based, CLI + LSP. Format, lint, validate.tomli, Python parser; standard library in 3.11+ astomllib.go-toml, Go parser.@iarna/toml, Node parser.
Editor support
- VS Code:
Even Better TOMLextension usestaploLSP. - JetBrains: built-in TOML support.
- Vim/Neovim:
tomlfiletype +taploLSP.
Schemas
TOML files can be validated against JSON Schema:
Cargo.toml: schema published by Rust team.pyproject.toml: schema inpackaging.python.org.- Custom schemas: write your own; Taplo can validate against them.
Pre-commit
Cargo Versioning Cheatsheet
TOML for Cargo.toml dependencies has its own version syntax:
The caret is the default, "1.0" means "^1.0" means "1.x, no breaking change."
Privacy
TOML formatting runs entirely in JavaScript in your browser: tokenize, parse, validate, reformat. Open DevTools Network during use: zero outbound requests. Config files often hold infrastructure context, DB hosts, internal service URLs, private registry sources, sometimes embedded credentials. A formatter that uploaded would be leaking architectural information. This tool keeps everything local; what you paste stays in the tab.
03 Where TOML Lives in the Real World
TOML's adoption is concentrated in toolchain configs where humans edit by hand and tools depend on round-trip stability. These are the files you'll usually be cleaning up.
-
Cargo.tomlRust's package manifest. Dependency entries drift between inline-table and dotted-key forms as people copy-paste fromcrates.io, formatting normalizes them so diffs stop being noisy. -
pyproject.tomlPer PEP 518 / 621, the single source of truth for Python projects.[tool.ruff],[tool.pytest], and[project]all share the file, clean section grouping matters. -
Hugo
config.tomlStatic-site configs with menu definitions and per-language overrides nest deeply via[[menu.main]]. Formatting makes it easy to spot the duplicateweightthat broke the nav order. -
GitHub Pages / Zola / Netlify configs Most static-site generators use TOML for their root config. A consistently formatted file makes
git blameacross years actually navigable. -
Tauri
tauri.conf.json+Cargo.tomlTauri apps split build config between Rust (TOML) and frontend (JSON). Keeping the TOML half tidy is the difference between a clean release pipeline and a confused one.
04 Worked Examples
# Inline-table form
package = { metadata = { docs = { features = ["full"] } } }
[package.metadata.docs]
features = ["full"]The TOML 1.0.0 spec is explicit: inline tables are immutable after they're written. You can't add a key to an inline table from another statement. If you need to extend package.metadata.docs later in the file, use the dotted-header form, formatting that promotes inline → header trades verbosity for editability.
[[bin]][[bin]]
name = "server"
path = "src/server.rs"
[[bin]]
name = "worker"
path = "src/worker.rs"
{
"bin": [
{ "name": "server", "path": "src/server.rs" },
{ "name": "worker", "path": "src/worker.rs" }
]
}A common bug: writing [bin] twice (single brackets). The second occurrence is a redefinition error per spec, not a second entry. Double-bracket [[…]] is the only way to append. Formatters that "fix duplicate sections" by merging them silently corrupt this case, verify the array length after round-trip.
offset_dt = 1979-05-27T07:32:00-08:00
local_dt = 1979-05-27T07:32:00
local_date = 1979-05-27
local_time = 07:32:00offset_dt -> OffsetDateTime (timezone-aware, RFC 3339)
local_dt -> LocalDateTime (no zone; "wall-clock")
local_date -> LocalDate
local_time -> LocalTimeTOML 1.0.0 references RFC 3339 directly. The distinction between offset and local matters for scheduling configs, a cron-like job at 07:32:00-08:00 behaves differently in DST than the same time written as a local datetime. Formatters must never "normalize" a timezone, even to UTC.
05 Related Tools
TOML usually appears alongside its sibling config formats. These help you move data across the boundary.
JSON Formatter
When a build script wants JSON, convert your Cargo.toml sub-section out and confirm the type fidelity (integers vs floats vs datetimes) before piping further.
.env Parser
TOML for structured config, .env for flat secrets. This tool helps when you're migrating between the two during a 12-factor cleanup.
Dockerfile Generator
Rust and Python projects driven by Cargo.toml / pyproject.toml often need a matching multi-stage Dockerfile, generate the scaffold and wire it in.