iLoveConverter
Categories 11 categories
Data TOML

TOML, Explained

iLoveConverter Team 3 min read

On this page

TOML (Tom’s Obvious Minimal Language) was created in 2013 by Tom Preston-Werner, one of GitHub’s founders, with a single goal: a configuration format that is painfully obvious to parse and write. Unlike YAML, which has dozens of ways to express the same thing, TOML has exactly one way. Unlike JSON, it supports comments and dates. Unlike INI files, it is hierarchical and typed. Today TOML powers Python’s pyproject.toml, Rust’s Cargo.toml, Go module manifests, and hundreds of developer tools.

What TOML looks like

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "my-package"
version = "0.1.0"
description = "A sample package"
requires-python = ">=3.8"

[project.optional-dependencies]
dev = ["pytest", "ruff"]

Every section is a [section.header]. Every key-value pair is on its own line. Strings use double quotes, numbers don’t, dates are literal. No surprises.

Technical details

AspectDetails
Spec versionTOML 1.0.0 (2021)
Data typesString, Integer, Float, Boolean, Datetime, Array, Table, Inline Table
Comments# to end of line
IndentationNot significant — layout is purely aesthetic
TablesHierarchical via [a.b.c] headers
Arrays[1, 2, 3] or multi-line with commas
File extension.toml

TOML vs YAML vs JSON

FeatureTOMLYAMLJSON
CommentsYesYesNo
Native datesYesYesNo
Uniqueness of styleStrict (one way)Flexible (many ways)Strict
Readability at scaleExcellentGoodFair
Arrays of tables[[product]]- product:Nested objects
Typed valuesExplicitImplicit (inferred)Implicit
Learning curveLowModerateLow

Conversion routes

  • TOML to JSON — expand table headers into nested objects; ideal for passing configs to web APIs.
  • JSON to TOML — flatten nested objects into section headers; great when adopting TOML for existing projects.
  • YAML to TOML — a natural migration path for teams tired of YAML’s indentation edge cases.
  • TOML to INI — lose nesting but gain compatibility with legacy Windows tools.

Common mistakes

  • Duplicate keys — TOML forbids them. Two [section] blocks with the same name merge their keys, but you cannot redefine a key.
  • Indentation confusion — unlike YAML, indentation in TOML is cosmetic. Over-indenting a key does not change its parent table.
  • Arrays vs tables — [[name]] creates an array of tables; [name] creates a single table. Mixing them under the same name is an error.
  • Case sensitivity — keys are case-sensitive. Name and name are different keys.

FAQ

Why does Python use TOML for pyproject.toml?

PEP 518/621 chose TOML because it is simple, well-specified, supports the metadata types Python projects need, and avoids YAML’s parsing ambiguity. Every Python package built today uses TOML as its canonical manifest.

In developer tools, TOML dominates for its clarity. In infrastructure (Kubernetes, Docker), YAML remains king. The two serve different niches — TOML for authoring, YAML for templating.

Can TOML represent everything YAML can?

No. TOML lacks anchors/aliases, custom tags, and some of YAML’s string scalar styles. But for configuration use cases — the problem TOML was designed to solve — it covers everything needed and does so unambiguously.

How do I convert a huge YAML file to TOML?

You can’t fully automate it if the YAML uses anchors or deep nested maps with arrays of tables. But most simple YAML configs (like those used in CI pipelines) convert cleanly. Just remember: if the YAML relies on indentation sensitivity, TOML won’t replicate that structure.

Try it yourself — free, right in your browser

Everything mentioned in this guide runs locally on this site: no upload, no watermark, no sign-up.

Format deep-dives: TOML (.toml) , YAML (.yml.yaml) , JSON (.json)