"category": "format-converter",

TOML to JSON Converter

"tldr": Paste TOML - Cargo.toml, pyproject.toml, any config - and get pretty-printed JSON with types preserved.

Convert any TOML document - a Cargo.toml, pyproject.toml, or application config - into pretty-printed JSON. Tables become objects, arrays of tables become arrays of objects, and TOML dates, integers, and floats map to their closest JSON representations.

{"toml": "json"}

The usual reason to do this: tooling. jq, JSON Schema validators, and most APIs speak JSON, not TOML. Converting lets you query a Cargo.toml with jq or validate a pyproject.toml against a schema without writing a parser.

How to convert TOML to JSON

  1. 1Paste your TOML - full TOML 1.0 is supported, including dotted keys and arrays of tables.
  2. 2Syntax errors are reported with the line where parsing failed.
  3. 3[[array.of.tables]] sections become JSON arrays of objects.
  4. 4Copy the pretty-printed JSON output.

Convert TOML to JSON in code

Python 3.11+ (stdlib)
import json, tomllib

with open("pyproject.toml", "rb") as f:
    data = tomllib.load(f)
print(json.dumps(data, indent=2, default=str))
Query a Cargo.toml with jq
# convert here, then:
jq '.dependencies | keys' cargo.json

Frequently asked questions

What happens to TOML dates and times?

TOML has first-class datetime types; JSON does not. They convert to ISO 8601 strings - the standard JSON convention - so 2026-07-30T12:00:00Z becomes the string "2026-07-30T12:00:00.000Z".

What does [[double brackets]] mean in my TOML?

An array of tables: each [[workers]] section appends one object to the workers array. In JSON it becomes "workers": [{...}, {...}] - which is often the "aha" of seeing your TOML as JSON.

Are comments preserved?

No - JSON has no comments, so # lines are dropped. If you need to round-trip a commented config, keep TOML as the source of truth and generate JSON only for tooling.

Last updated:

You might also need

Free and in-browser, like everything on JSON Console. Browse all tools →