json:yaml

TOML to JSON converter

Tables become nested objects and [[arrays of tables]] become arrays. Useful for feeding a pyproject.toml or Cargo.toml into a script that speaks JSON.

TOML
JSON

      
Paste TOML to convert.

Conversion happens in this browser tab. Nothing is uploaded, logged, or stored.

How tables become objects

A [table] header creates a nested object, with dots in the header creating further nesting. A [[table]] header appends to an array. Key-value pairs attach to whichever table header last appeared above them.

TOML
title = "example"

[owner]
name = "Ada"

[[servers]]
host = "alpha"

[[servers]]
host = "beta"
JSON
{
  "title": "example",
  "owner": { "name": "Ada" },
  "servers": [
    { "host": "alpha" },
    { "host": "beta" }
  ]
}

Type handling

TOMLJSON
"text" or 'text'String
42, 3.14Number
true, falseBoolean
[1, 2, 3]Array
1979-05-27T07:32:00ZString — JSON has no date type
# commentDropped

Dates are the notable case. TOML has first-class datetime literals; JSON does not. They come through as ISO 8601 strings, which is the convention every JSON consumer already expects, but the type information is gone.

Supported subset

This handles the constructs that appear in real configuration files: basic and literal strings, integers, floats, booleans, arrays, tables, dotted table headers, and arrays of tables. Multi-line strings, inline tables, hexadecimal and octal integers, and offset datetimes with fractional seconds are edge cases you are more likely to meet in a spec test than in a pyproject.toml.

To write a TOML file rather than read one, use JSON to TOML. The JSON formatter will tidy the output if you plan to commit it.

For full TOML 1.0 coverage, use a dedicated library:

# Python 3.11+, standard library
import tomllib, json
with open("pyproject.toml", "rb") as f:
    print(json.dumps(tomllib.load(f), indent=2))
# command line
yq -p=toml -o=json '.' Cargo.toml

Nothing is transmitted

Configuration files are read here, not collected. A TOML file typically holds database URLs, API keys, and the internal endpoints an application talks to, which is a poor thing to hand to an unfamiliar website.

You are not handing it over. Parsing happens in your browser, the JSON is built in the same tab, and closing the page is the end of it.

Questions people ask

What happens to TOML datetimes?
They become ISO 8601 strings, because JSON has no date type. That is the convention every JSON consumer already expects, but the type information is gone.
Are comments preserved?
No. JSON has no comment syntax, so they are dropped.
Is the whole TOML 1.0 specification supported?
The constructs that appear in real config files are: strings, numbers, booleans, arrays, tables, dotted headers, and arrays of tables. For full coverage use Python's tomllib, which is in the standard library from 3.11.
How do I convert a pyproject.toml on the command line?
python -c 'import tomllib,json,sys; print(json.dumps(tomllib.load(open(sys.argv[1],"rb")),indent=2))' pyproject.toml