TOML to JSON Converter
runs in your browserConvert TOML to JSON and JSON back to TOML, with clear reporting for the values TOML cannot hold, such as null and a non-table root.
TOML has no null and must start with a table, so those cases are reported rather than quietly changed.
TOML
JSON
about this tool
Both directions
TOML to JSON for reading a config file programmatically, and JSON to TOML for
producing one. TOML is what pyproject.toml, Cargo.toml, netlify.toml and
a growing number of tools use for configuration.
Why TOML exists
It was designed as a reaction to both of its neighbours. INI files have no
specification and no nesting. YAML has a specification so large that its edge
cases are famous — the no that becomes false, the tab that is illegal, the
version string that turns into a float. TOML aims for an unambiguous format that
still reads like a config file, and it largely succeeds: there is one way to
interpret a TOML document, and it is the obvious one.
The cost is verbosity. Deeply nested data is clumsier in TOML than in either JSON or YAML, which is why it suits flat-ish configuration and not arbitrary data.
The YAML converter page lists those YAML surprises in detail.
Null has no equivalent
This is the one conversion problem worth knowing about, and the tool reports it explicitly with the path of every offending value.
TOML has no null. The format's position is that an absent value should be an
absent key, so there is nothing to convert a JSON null into. When your JSON
contains nulls you have to decide, per field, whether the key should be omitted
entirely or given a meaningful empty value such as "" or 0. Only you know
which, so the tool tells you where they are instead of choosing for you.
Dates are a real type
Unlike JSON, TOML has first-class dates and times: offset date-times, local date-times, plain dates and plain times, all unquoted. Converting to JSON turns them into strings, because JSON has no date type — which means a TOML to JSON to TOML round trip returns quoted strings where you had dates. The tool notes when a document contains them.
Tables and arrays of tables
TOML's [section] is a table, and [[section]] is an array of tables — the
form used for a repeated block such as several dependencies or several
environments. In JSON those are an object and an array of objects respectively,
which is the mapping applied here.
Local
Both directions parse in the browser. Config files carry deployment details and occasionally credentials, so nothing is transmitted.
questions
- What happens to null values when converting JSON to TOML?
- TOML has no null, on the principle that an absent value should be an absent key. Every null is reported with its path so you can decide per field whether to drop the key or use a meaningful empty value; the tool will not choose for you.
- Why use TOML instead of YAML?
- Because there is one obvious way to read a TOML document. YAML's specification is large enough that its edge cases are famous — no becoming false, illegal tabs, version strings turning into floats. The cost is that deep nesting is clumsier in TOML.
- How do TOML tables map to JSON?
- A [section] table becomes an object, and an [[section]] array of tables becomes an array of objects. That second form is what TOML uses for a repeated block such as several dependencies or environments.
- Are TOML dates preserved through a round trip?
- No. TOML has real date and time types while JSON has none, so dates become strings on the way to JSON and stay strings on the way back. The tool notes when a document contains them.
- Where is TOML actually used?
- In pyproject.toml for Python packaging, Cargo.toml for Rust, netlify.toml, and a growing number of other tools that wanted configuration without YAML's ambiguities.