T tomlkit·org
Inspect Formatter Validator Convert TOMLJSON JSONTOML TOMLYAML YAMLTOML INITOML TOMLINI .envTOML TOML.env TOMLTS Transform Sort keys Flatten Minify Compare Diff Merge

TOML to JSON Converter

updated 8 June 2026

Paste TOML on the left, get JSON on the right. Everything runs in your browser — files never leave your machine.

TOML 1.0 · ISO 8601 dates

What this tool does

It parses TOML with the spec-compliant smol-toml parser, then serializes the value tree as JSON with JSON.stringify. Tables become objects, arrays-of-tables become arrays of objects, dotted keys expand into nested objects, and TOML datetimes are encoded as either ISO 8601 strings or tagged {"$date":…} objects, your choice.

The intent it closes: "I have a Cargo.toml or pyproject.toml and I need its data as JSON" — to feed a JavaScript or TypeScript app, pipe through jq, post to an API, or load into any tool that reads JSON but not TOML.

One thing to expect: comments don't carry over. JSON has no comment syntax, so the # lines in your TOML are dropped during parsing.

When you'd reach for it

  • Feed a JS/TS app. Turn a project's TOML config into a JSON object you can import or fetch.
  • Pipe through jq. Get JSON so you can query and reshape a config on the command line.
  • Inspect a Cargo.lock or lockfile. JSON is easier to scan and diff programmatically than nested TOML.
  • Minify for transport. Pick Minified indent to produce the most compact JSON for an API body or env var.
  • Keep dates as real values downstream. Choose the {"$date":…} encoding so a consumer can distinguish a datetime from an ordinary string.
  • Match a Windows toolchain. Switch EOL to CRLF when the JSON is headed for a tool that expects Windows line endings.

How the conversion works

One click of Convert runs three stages.

1. Parse the TOML

The full TOML 1.0 grammar is parsed into a value tree — dotted keys collapse into nested tables, integers keep hex/octal/binary intent, datetimes become date-shaped values. A parse failure shows the line and column in the status bar and no JSON is produced.

2. Encode dates

JSON has no native date type, so every TOML datetime is transformed before stringifying. Under ISO 8601 string it becomes a plain quoted string; under {"$date":…} it becomes a tagged object a consumer can recognize and rehydrate. The pass is recursive — dates nested anywhere in the tree are converted.

3. Stringify

JSON.stringify writes the tree using the Indent and Sort options. Alphabetical sorts keys recursively at every depth. Unless output is Minified, a trailing newline is appended; EOL then optionally rewrites \n to \r\n.

Options reference

Indent

2 spaces and 4 spaces are pretty-printed; Tab indents with a tab character; Minified removes all whitespace and the trailing newline for the smallest possible payload.

Sort

Preserve order keeps the order keys appeared in the TOML. Alphabetical sorts object keys A–Z recursively, which makes the JSON diff-stable and easy to scan.

Dates

ISO 8601 string writes a datetime as "1979-05-27T07:32:00Z" — universally readable, but indistinguishable from a string that happens to look like a date. {"$date":…} wraps it as {"$date":"1979-05-27T07:32:00Z"} so a downstream parser can tell it was a real datetime and cast it back.

EOL

LF (\n) is the default and correct for Unix, macOS, and most tooling. CRLF (\r\n) rewrites line endings for Windows-only consumers that insist on them.

Output and mapping rules

  • Tables → objects. [server] becomes "server": { … }.
  • Arrays-of-tables → arrays of objects. [[users]] blocks become a JSON array of objects.
  • Dotted keys → nested objects. site.name = "x" becomes "site": { "name": "x" }.
  • Numbers and booleans map straight across; strings stay strings.
  • Datetimes encode per the Dates option (ISO string or $date object).
  • Comments are stripped — JSON can't hold them.
  • Download: output.json, content type text/plain;charset=utf-8.

Example

Input (TOML):

[server]
port = 8080
enabled = true
tags = ["api", "prod"]

Output (JSON, defaults — 2-space, ISO dates):

{
  "server": {
    "port": 8080,
    "enabled": true,
    "tags": ["api", "prod"]
  }
}

Integers, booleans, and arrays map 1:1. Only TOML-specific types — datetimes — need the encoding choice described above.

Recipes by intent

Get a compact body for an API or env var

Set Indent to Minified. The output is a single line with no trailing newline — the smallest valid JSON for the same data.

Produce diff-stable JSON

Choose Alphabetical sort. Keys are ordered A–Z at every depth, so re-converting the same config never reshuffles the file in version control.

Preserve dates as real datetimes

Switch Dates to {"$date":…}. A consumer that understands the tag can rebuild a real date object instead of guessing whether a string is a timestamp.

Hand JSON to a Windows-only tool

Set EOL to CRLF so line endings match what the consuming program expects on Windows.

Limits and performance

  • In-memory. Input, parsed tree, and JSON output coexist in memory. Project configs and lockfiles are instant; a very large TOML can stutter while the JSON string is assembled and painted.
  • The textarea is the bottleneck on big output. Past tens of megabytes, use Download .json rather than Copy.
  • Round-trip caveat. JSON is less expressive than TOML — inline-vs-block table choices and comment placement don't survive a TOML → JSON → TOML trip even though the data does.

Errors and how to fix them

A parse error with a line and column

The input isn't valid TOML 1.0. Common causes: a string value left unquoted, single quotes where escaping needs double quotes, a trailing comma in an inline table, or a duplicate key. The TOML Validator points at the exact spot.

The output is just {}

Your input parsed but had no data — usually a file of only comments or empty [tables]. Add key-value pairs and re-run.

My dates came out as plain strings

That's the ISO 8601 string default. Switch Dates to {"$date":…} if you need the datetime to stay distinguishable from an ordinary string.

My # comments are gone

Expected — JSON has no comment syntax, so comments are dropped during parsing. Keep the TOML source if you need to retain them.

FAQ

Is my configuration data private?

Yes. smol-toml runs entirely in your browser — no upload, no network request with your content. You can convert offline after the page loads.

Does it support the full TOML 1.0 spec?

Yes — heterogeneous arrays, dotted keys, all date/time formats, hex/octal/binary integers, and arrays-of-tables. It tracks modern Cargo and Poetry files.

How are nested tables handled?

Nested tables ([a.b.c]) become nested JSON objects, and arrays-of-tables ([[item]]) become arrays of objects — a 1:1 mapping that follows the standard TOML-to-JSON model.

Can I convert the JSON back to TOML?

Yes — use JSON to TOML. The data round-trips, though JSON can't record TOML's formatting choices, so layout details won't return.