b2KIT

TOML Formatter & Validator

Format and validate TOML configuration files with error highlighting and section sorting.

Tested tool guide Tested browser tools Checked August 16, 2026

What TOML Formatter & Validator does, with a checked example

Paste any TOML document and get a normalized, section-sorted copy plus a spec check. The tool parses the text against the TOML grammar, and only a valid document is re-emitted, with canonical spacing and the top-level tables in alphabetical order; a parse failure is reported at the exact line and column where it occurred and highlighted in the source. The usual surprise is how strict TOML is: strings must be quoted, booleans are only true or false, numbers and dates are typed values, and duplicate keys are rejected - so a config file another tool tolerated can fail here.

Worked example

A concrete input and expected output from the current implementation.

Input

[package]
name="demo"
version="0.1.0"

[build]
optimize=true

Expected output

[build]
optimize = true

[package]
name = "demo"
version = "0.1.0"

The tables are reordered alphabetically - [build] comes before [package] - and the spacing around the equals signs is normalized to one space. Key order inside each table is unchanged: sorting applies to sections, not keys.

How the result is produced

1

Validation pass

The pasted text is parsed against the TOML grammar before any formatting happens. Keys, strings, numbers, dates, arrays, and tables must all be well-formed; a malformed construct is flagged with its line and column, and the offending span is highlighted in the source. If nothing is wrong, the document is considered valid and moves on to formatting.

2

Formatting and sort pass

On a valid parse, the document is re-emitted in canonical form: one space around each equals sign and one blank line between tables. The top-level tables are then sorted alphabetically, so [build] moves ahead of [package], while keys inside each table keep the order they were written in. The result is a stable layout that diffs cleanly against later edits.

Good uses

  • Preparing a Cargo.toml or pyproject.toml for commit after hand-editing, so spacing is uniform and sections read in a predictable order.
  • Finding out why a program refuses to load a config file: paste it, and the highlighted line and column show where the document stops being valid TOML.
  • Normalizing two copies of a config before diffing them, so real value changes stand out instead of whitespace noise.

Limits and checks

  • The check covers the TOML grammar only. A file can parse cleanly and still be rejected by the tool that reads it: pyproject.toml is also validated against PEP 621, and Cargo applies its own rules to dependency tables and version strings.
  • Lenient parsers accept what TOML forbids - unquoted strings, yes/no as booleans, duplicate keys. If a file that worked elsewhere is flagged here, the error is real under the TOML 1.0 grammar, not a false positive.
  • Section sorting moves content, so line numbers shift. Error messages and logs that reference line numbers in your original file will point at the wrong place in the formatted copy; keep the original while chasing line-referenced errors.

Common questions

My config file holds API keys - is it safe to paste it in?

Yes. Processing happens entirely in your browser - the pasted text is parsed locally and never uploaded or stored. Treat the page like any tool handling secrets: paste it, copy the formatted result back, and clear the input when you are finished.

Will it catch mistakes specific to Cargo.toml or pyproject.toml?

No. It validates against the TOML grammar itself, so it catches syntax errors in either file, but it does not know either tool's schema: a dependency with an invalid version requirement, or a pyproject.toml missing fields PEP 621 requires, will pass. Use this for syntax, then run the consuming tool's own validation.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools