TOML Formatter
Format, validate, and beautify TOML configuration files like Cargo.toml and pyproject.toml directly in your browser.
TOML formatter and validator
Waiting for TOML
Runs in your browser. Your TOML is not uploaded during normal formatting and validation.
Shortcuts: Ctrl/Cmd+Enter format · Ctrl/Cmd+Shift+V validate · Ctrl/Cmd+L focus input · Ctrl/Cmd+Shift+D diff · Esc close
0 lines · 0 chars · ~0 bytes
Formatted TOML
0 lines · 0 chars
What Is a TOML Formatter?
A TOML formatter parses valid TOML and rewrites it with consistent spacing, indentation, table layout, and line breaks while keeping the configuration's meaning intact. It is a TOML beautifier and pretty printer for configuration files, not a general-purpose text indent tool.
TOML is commonly used for files such as Cargo.toml and pyproject.toml. A dedicated formatter is needed because TOML is not JSON and is not the same as INI: it has typed values, tables, arrays of tables, and comments.
How to Use the TOML Formatter
- Paste or upload TOML.
- The tool checks syntax and shows Valid TOML or Invalid TOML.
- Choose 2-space or 4-space indentation if needed.
- Click Format to beautify valid input.
- Review the formatted output.
- Use Diff to see exactly what changed.
- Copy or download the result.
If the input is invalid, fix the reported line and column, then validate again. The formatter does not invent a valid document from broken syntax.
Format vs Validate
Formatting and validating are separate actions. A TOML linter or syntax checker reports problems. A pretty printer rewrites valid source.
| Action | Purpose | Changes input? |
|---|---|---|
| Format | Beautifies valid TOML | Yes — writes formatted output |
| Validate | Checks TOML syntax | No |
| Diff | Shows formatting changes | No |
| TOML → JSON | Converts parsed TOML to JSON | Creates new JSON output |
Format Cargo.toml Files
Cargo.toml is the TOML manifest used for Rust package and workspace configuration. A Cargo.toml formatter here checks TOML syntax and improves readability for tables such as [package], [dependencies], [[bin]], and [workspace].
This is not Cargo package validation. It does not verify crate names, feature flags, edition values, or workspace membership the way cargo does. Use it to format Cargo.toml and catch TOML grammar mistakes before you run Cargo.
Format pyproject.toml Files
pyproject.toml is a TOML configuration file used in modern Python project tooling. Typical tables include [build-system], [project], and [tool] namespaces.
A pyproject.toml validator on this page means TOML syntax validation. It does not replace Poetry, PDM, Hatch, Ruff, or pytest semantic checks. If those tools reject a file that parses as TOML, the problem is in the ecosystem schema, not the TOML grammar.
What Is TOML?
TOML means Tom's Obvious Minimal Language. It is a human-readable, case-sensitive, UTF-8 configuration format. A TOML parser reads key/value pairs, tables, arrays, inline tables, arrays of tables, strings, numbers, booleans, and date/time values.
- Tables use
[table]. Nested tables stay nested; they are not flattened. - Arrays of tables use
[[products]]. That is not the same as[products]. - Inline tables use
{ key = "value" }. - Dotted keys such as
physical.colorexpress nested structure. - Comments begin with
#outside strings.#inside a URL string is not a comment.
TOML Formatting Examples
Spacing around keys
# Input [database] host="localhost" port=5432 enabled=true # Formatted [database] host = "localhost" port = 5432 enabled = true
Cargo-style package table
[package] name = "demo" version = "0.1.0"
Arrays of tables
[[products]] name = "Hammer" price = 19.99 [[products]] name = "Nail" price = 3.49
Comment preservation
Comments are valid TOML. The formatter keeps them when it rewrites the document.
# Production API url = "https://api.example.com"
TOML vs JSON and YAML
Use a TOML-specific formatter when the file is TOML. JSON and YAML tools will misread comments, dates, and table syntax.
| Format | Strength | Watch-out |
|---|---|---|
| TOML | Human-friendly configuration, comments, typed dates, tables | Needs a TOML parser |
| JSON | Machine-oriented data interchange, strict syntax | No comments |
| YAML | Flexible configuration and data | Indentation-sensitive |
If the file is JSON-shaped data, continue with the JSON Formatter. Use the YAML Formatter when the configuration is YAML rather than TOML. To compare two revisions as plain text, open the Text Diff Tool.
Common TOML Formatting Use Cases
- Rust Cargo projects and workspaces
- Python projects that use pyproject.toml
- CI and development-tooling configuration written in TOML
- Static-site configuration such as Hugo config.toml
- CLI and application configuration
- Cleaning generated TOML before a pull request
- Reviewing formatting changes before commit
Common TOML Formatting and Syntax Mistakes
- Duplicate keys — the same key cannot appear twice in one table.
- Duplicate table definitions —
[server]cannot be opened twice as a standard table. - Invalid table headers — missing
]or mixing[table]with[[table]]. - Malformed arrays — missing commas or an unclosed
[. - Unclosed strings — basic, literal, and multiline strings must terminate.
- Inline tables vs tables —
point = { x = 1 }is not[point]. - Comments mistaken for values —
#starts a comment only outside strings. - Invalid date/time syntax — offset and local date-times follow the TOML 1.0 forms.
- Quoted dotted keys —
site."google.com"is one dotted path, not a hostname rewrite. - Array-of-table syntax — changing
[[products]]to[products]changes meaning. - Assuming Cargo or Poetry validation — TOML syntax is not package metadata validation.
TOML Formatter Limitations
This tool validates TOML syntax. It does not automatically validate Cargo semantics, Python package metadata, Poetry or PDM rules, Ruff settings, pytest options, Deno configuration, or Hugo-specific keys unless those validators are implemented separately. They are not implemented here.
JSON conversion drops comments because JSON has no standard comment syntax. Date values are serialized as ISO-8601 strings. For JSON documents that fail to parse, use the JSON Validator.
Formatter, Beautifier, Validator, and Parser
People search for a TOML formatter online, a TOML beautifier, a pretty printer, a TOML validator, a linter, or a syntax checker. On this page those names describe one browser workflow: parse the document, report grammar errors with line and column, then optionally emit formatted TOML. Format TOML online here without uploading the file. The same parser is used for Cargo.toml and pyproject.toml because both are TOML documents.
TOML Formatter FAQ
What is a TOML formatter?
A TOML formatter parses valid TOML and rewrites it with consistent spacing, indentation, table layout, and line breaks while keeping the configuration's meaning intact.
What is TOML used for?
TOML is a human-readable configuration format. Common files include Rust Cargo.toml, Python pyproject.toml, and application or tooling config written as TOML.
How do I format a TOML file?
Paste or upload the file, choose 2-space or 4-space indentation if you want, then click Format. Copy or download the formatted output.
How do I validate TOML online?
Click Validate without changing the input. The syntax checker reports Invalid TOML with a category, line, column, and a source excerpt.
What is the difference between formatting and validating TOML?
Validate checks TOML syntax and leaves the source unchanged. Format beautifies valid TOML into a new output document.
Can this format Cargo.toml?
Yes. Cargo.toml is TOML, so the formatter can beautify and syntax-check it. It does not validate Cargo package or workspace semantics.
Can this format pyproject.toml?
Yes. It formats and syntax-checks pyproject.toml. It does not validate Poetry, PDM, Hatch, or other Python packaging rules.
Does the formatter support TOML 1.0?
Yes. The parser accepts TOML 1.0 constructs including tables, arrays of tables, inline tables, dotted keys, strings, numbers, booleans, and date/time values.
Are comments preserved?
Yes when formatting TOML. Comments are kept in the rewritten document. They cannot survive TOML → JSON because JSON has no standard comment syntax.
Does formatting change the meaning of my TOML?
No. Formatting must not change key names, values, array order, table relationships, booleans, or dates. Optional key sorting is off by default because it changes source order.
Can I upload a .toml file?
Yes. Upload or drop a .toml or .txt file. The file is read in your browser and is not uploaded to EverydayTools for normal formatting.
Can I format multiple TOML files at once?
Yes. Upload a .zip that contains .toml files. Each file is formatted or marked invalid. Non-TOML files are left unchanged in the download.
Can I download the formatted TOML?
Yes. Download a .toml file from the output panel, or download a formatted ZIP after a multi-file run.
Can I compare the original and formatted TOML?
Yes. After Format, open Diff to see added, removed, and changed lines. Diff is not loaded until you ask for it.
Can I convert TOML to JSON?
Yes, as a secondary action. Dates become ISO-8601 strings. Comments are dropped. JSON → TOML is available but cannot restore TOML comments or native date types.
Is my TOML uploaded to a server?
No. Formatting and validation run in your browser. EverydayTools does not upload TOML during normal use and does not put your config in the URL.
Does this validate Cargo.toml or pyproject.toml semantics?
No. It validates TOML syntax only. Cargo, Poetry, and similar tools still own package and workspace rules.