induwara.lk
induwara.lkDeveloper · Config

TOML to JSON Converter — bidirectional

Convert TOML to JSON and JSON back to TOML right in your browser. Spec-compliant (TOML v1.0.0, JSON RFC 8259 / ECMA-404), with type-mapping notes, error positions, and a round-trip integrity check. No signup, no uploads, sources cited below.

By Induwara AshinsanaUpdated Jun 24, 2026
TOMLJSON converter
Valid · round-trip OK
TOML input15 lines · 262 ch

Runs entirely in your browser — nothing is uploaded.

JSON output25 lines · 397 ch
Round-trip verified

Structure preserved exactly — fully reversible.

Type-mapping notes

No special type conversions in this input — every value maps directly.

Sources cited: TOML v1.0.0 spec · JSON RFC 8259 · smol-toml. Dates become ISO-8601 strings and JSON null keys are dropped when targeting TOML — see the notes above and the FAQ below.

How it works

This is a deterministic format transform, not a calculator. It parses your input into an in-memory data structure, then serialises that structure into the target format. TOML parsing and serialisation use smol-toml (a zero-dependency library that passes the official toml-testsuite); JSON uses the browser's native JSON.parse and JSON.stringify. Everything runs client-side, so your config never leaves the page.

TOML → JSON

  1. Parse the TOML per the v1.0.0 grammar. Tables and inline tables become JSON objects; arrays of tables ([[x]]) become arrays of objects; dotted headers like [tool.ruff] nest accordingly.
  2. Map each scalar: string → string, integer and float → number (JSON does not distinguish the two), boolean → boolean. Because JSON has no date type, every TOML offset date-time, local date-time, local date, and local time is emitted as an ISO-8601 string — the one lossy edge, surfaced in the notes panel.
  3. Serialise with the chosen indentation (2, 4, tab, or minified) and, optionally, alphabetically sorted keys for stable version-control diffs.

JSON → TOML

  1. Parse the JSON per RFC 8259 / ECMA-404. The root must be an object, because TOML's top level is always a table — a bare array or scalar is rejected with a specific message.
  2. Reconcile against TOML's data model. null has no TOML representation, so a null-valued key is omitted (and counted in the notes); a null inside an array is a hard error, because TOML arrays cannot contain one. Arrays whose items are all objects are written as arrays of tables.
  3. Serialise with smol-toml, which emits spec-compliant tables, inline tables, and arrays of tables.

After either direction, the tool runs a round-trip integrity check: it re-parses its own output and structurally compares it to your input, accounting for the two documented lossy edges (dates becoming strings, null keys being dropped). A clean match shows “round-trip verified”; an expected lossy case shows “converted with notes”; anything else is flagged as a mismatch so you know not to trust it. Comments are not preserved in either direction — both parsers discard them.

Worked examples

1 · pyproject.toml snippet → JSON

TOML in

[project]
name = "my-app"
version = "1.0.0"
dependencies = ["requests", "flask"]

[tool.ruff]
line-length = 88

JSON out (indent 2)

{
  "project": {
    "name": "my-app",
    "version": "1.0.0",
    "dependencies": ["requests", "flask"]
  },
  "tool": { "ruff": { "line-length": 88 } }
}

The dotted header [tool.ruff] nests ruff under tool. No dates or nulls, so the round-trip is lossless and fully reversible.

2 · JSON with an array of tables → TOML

JSON in

{
  "server": { "host": "localhost", "port": 8080 },
  "users": [ { "name": "alice" }, { "name": "bob" } ]
}

TOML out

[server]
host = "localhost"
port = 8080

[[users]]
name = "alice"

[[users]]
name = "bob"

An array of objects becomes an array of tables ([[users]]) — the canonical TOML form. Converting it back yields the identical structure.

3 · Typed scalars and the lossy date edge → JSON

TOML in

created = 2026-06-24T10:30:00Z
enabled = true
ratio = 3.14
count = 42

JSON out (indent 2)

{
  "created": "2026-06-24T10:30:00.000Z",
  "enabled": true,
  "ratio": 3.14,
  "count": 42
}

The notes panel reports: 1 offset date-time → ISO-8601 string. Converting this JSON back to TOML produces created = "2026-06-24T10:30:00.000Z" as a string, not a TOML date — expected, because JSON had already lost the date type.

Frequently asked questions

Sources & references

Conversion behaviour was last verified against the TOML v1.0.0 spec, RFC 8259 / ECMA-404, and smol-toml v1.7.0 on 2026-06-24. The three worked examples above round-trip exactly as documented.

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, an edge case, or a TOML file that doesn't round-trip?

Email me at [email protected] — most fixes ship within 24 hours.