Loading…

About Online TOML Formatter

Messy `pyproject.toml`, `Cargo.toml` or `poetry` configs? Paste your TOML or drop a file and our formatter will normalize whitespace, tidy arrays and inline tables, and keep your sections consistently spaced. Ideal for Python, Rust, Go, static-site generators and any project that leans on TOML for configuration.

Key Features of the TOML Formatter

  • **One-click beautifier** for TOML configuration files and snippets
  • **Configurable indent size** from 1 to 8 spaces via the *Indent Size* slider
  • **Indent style toggle** – choose between spaces or tabs for indentation
  • **Wrap / Line Length** control to keep long arrays and inline tables within a chosen column width
  • Supports `.toml` files such as `pyproject.toml`, `Cargo.toml`, `Pipfile.toml`, `poetry.toml` and more
  • Prettier-based TOML parser that understands dates, arrays, nested tables and inline tables
  • Stable, idempotent formatting – rerunning it on the same file won’t cause formatting drift
  • One-click copy of the formatted output, ready for your editor or commit

🛠️ How to Format TOML Files Online for toml-formatter

1

1. Paste or Upload Your TOML

📥 Paste TOML into the editor or drag-and-drop a `.toml` file such as `pyproject.toml` or `Cargo.toml`. The tool parses the content as TOML, not generic INI/JSON.

2

2. Choose Indentation & Wrap Settings

⚙️ Use the **Indent Size** slider to choose how many spaces per indent level, and switch **Indent Style** to tabs if your project prefers them. Adjust **Wrap / Line Length** to control when long arrays or inline tables should wrap (or set it to `0` to effectively disable wrapping).

3

3. Click “Format”

🚀 Hit the **Format** button. The formatter will reflow arrays, clean up spacing around `=` and commas, normalize table spacing, and enforce consistent line breaks while preserving your data.

4

4. Review, Copy or Save

🔍 Compare the original and formatted TOML. When you’re happy, copy the result back into your editor or save it as a new `.toml` file in your project.

Technical Specifications

Supported TOML Features

The formatter is built for real-world project configs and understands modern TOML constructs.

FeatureSupportExamples / Notes
Tables & subtables✅ Full[tool.poetry], [project], [database.replica]
Arrays✅ FullInline arrays and arrays of tables
Inline tables✅ Fullservers = { alpha = "10.0.0.1", beta = "10.0.0.2" }
Dates & times✅ Full2025-09-23T10:20:30Z and local date formats
Comments✅ Preserved# comments stay near the settings they describe
Multiline strings✅ FullTriple-quoted TOML strings for long text blocks

Formatting Options (Mapped to Tool Controls)

These options are exposed directly in the UI and wired to the underlying Prettier TOML plugin:

OptionUI ControlRange / ValuesDefault
Indent sizeIndent Size slider1–8 spaces2 spaces
Indent styleIndent Style selectSpaces / TabsSpaces
Line lengthWrap / Line Length0–120 columns (0 = effectively no wrap)80 columns
End-of-lineEnd of line (internally)LF / CRLFLF in browser output

Input & Limits

The tool is optimized for small to medium TOML files commonly found in application repos.

ParameterValue / BehaviorNotes
File extensions.tomlAny TOML-based config file
MIME typesapplication/toml, text/x-tomlUsed for file detection in the dropzone
Max file size~5 MBLarger files may be slower and are better handled in CI
Max characters≈ 2,000,000Hard limit in the formatter runtime to avoid browser lockups

Validation & Error Handling

If your file isn’t valid TOML (e.g. missing `=` or mismatched quotes), the formatter will typically return a readable error instead of formatted output. Fix the indicated line and run the formatter again.

Command Line Alternatives for TOML Formatting

Love the result and want the same style in CI or pre-commit hooks? Here are CLI-friendly options:

Cross-platform (Node.js / Prettier)

Install Prettier and the TOML plugin

npm install --save-dev prettier prettier-plugin-toml

Adds Prettier and the TOML parser to your project.

Format a TOML file with Prettier

npx prettier --parser toml --write pyproject.toml

Rewrites `pyproject.toml` in place using Prettier’s TOML rules.

Linux / macOS / Windows (Taplo CLI)

Format TOML using Taplo

taplo fmt pyproject.toml

Another popular CLI formatter for TOML files.

Check formatting in CI

taplo fmt --check .

Fail the build if TOML files are not properly formatted.

Use this online tool for quick edits and experiments, then enforce the same style with Prettier or Taplo in your CI pipelines.

Common TOML Formatter Use Cases

Python Packaging (`pyproject.toml`)

Keep Python project metadata and tooling configuration clean and easy to review.

  • Align `[project]`, `[tool.poetry]` and `[tool.black]` sections.
  • Normalize dependency arrays and version specifiers.
  • Make config diffs easier to read in pull requests.
[project]
name = "my-app"
version = "0.1.0"

[tool.black]
line-length = 88
include = "\.(py|pyi)$"

Rust Projects (`Cargo.toml`)

Tidy Rust package manifests across workspaces and microservices.

  • Keep `[dependencies]` and `[dev-dependencies]` sorted and consistently spaced.
  • Normalize inline tables used for complex feature flags.
  • Standardize formatting across multiple crates in a workspace.
[package]
name = "my-crate"
version = "0.1.0"
edition = "2021"

[dependencies]
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1", features = ["full"] }

Static Sites & Tools (Hugo, Zola, etc.)

Clean TOML used for static-site generators and miscellaneous tooling.

  • Format `config.toml` for Hugo or other static site generators.
  • Keep multilingual configuration blocks readable.
  • Normalize long lists such as menu entries and taxonomies.

❓ Frequently Asked Questions

What is a TOML formatter?

A TOML formatter automatically restructures your TOML files so they follow a consistent style: it fixes indentation, aligns arrays and inline tables, normalizes spaces around `=` and commas, and preserves the data while making it easier to read and review.

📏How should I choose indent size and style?

If your team doesn’t have a preference, **2 spaces** is a good default. Match the style already used in your repo: if files are mostly indented with spaces, keep using spaces; if tabs are the team standard, switch the **Indent Style** to Tabs so new changes align with existing code.

🧪Does the formatter validate TOML syntax?

The underlying parser will reject invalid TOML (for example, missing `=` or mismatched quotes). In that case, the tool shows an error message instead of formatted output, so you can fix the problem and try again.

🔁Can running the formatter change my configuration behavior?

The formatter is designed to be **semantics-preserving**: it only changes whitespace and layout, not keys, values or table structure. As long as the original file is valid TOML, the meaning of your configuration should remain the same.

🔒Is it safe to format sensitive config files?

As with any online tool, avoid pasting extremely sensitive material like production secrets. For highly confidential configs, use a local TOML formatter (like Prettier or Taplo) inside your private development environment.

Pro Tips

Best Practice

Keep a nicely formatted `pyproject.toml` or `Cargo.toml` in your main branch, then enforce the same style in CI using Prettier or Taplo.

Best Practice

Format TOML before committing large dependency or config changes so your Git diffs focus on **actual changes**, not whitespace noise.

Best Practice

When refactoring configs, format the file first, commit, then change the values. This makes it easier to review what really changed.

Best Practice

Use the same **indent size** and **wrap length** across all your TOML files to make cross-project navigation and code reviews feel consistent.

Additional Resources

Other Tools