TOML to JSON

Converter

Parse a TOML document into JSON with tables, arrays, dates and multiline strings for inspecting, debugging and migrating project configuration files safely.

Converted
TOML
18 lines
JSON
26 lines

About TOML to JSON

Converting TOML to JSON is usually about letting a JSON-only consumer read the same configuration, for example feeding a local toolchain config into a front-end build or injecting configuration into a service whose contract is JSON. Compared with retyping it, conversion preserves structure and avoids low-level mistakes in nested tables. Conversion parses TOML into a tree and serializes it as JSON. The section-header syntax makes hierarchy explicit, so the resulting JSON structure is usually easy to read. The type differences need attention though, since date and time are their own type in TOML but can only be strings in JSON, and the serializer decides whether an offset and milliseconds are included. Confirm the shape before parsing it as a string downstream. Practical notes: After converting, verify the total key count and the count under each branch to confirm nothing was lost. Then inspect arrays: TOML permits mixed element types while most JSON consumers assume homogeneity, and a mixed array causes deserialization trouble. The specification does allow heterogeneous arrays; such data is exactly what breaks across languages, so decide up front whether to split it into separate fields. Limits: Comments are necessarily lost, so configuration that needs explanation belongs in a separate document. TOML expresses hierarchy with dots and those become nested objects, but when the source mixes keys that literally contain a dot with levels expressed through headers, the parse may not match intuition. That ambiguity should be removed in the source rather than patched afterwards. On numbers, TOML accepts hexadecimal and underscore separators while JSON output is uniformly decimal, so consumers relying on the original notation are affected. Data and privacy: such configuration files usually hold credentials and internal addresses. This tool converts in the browser without uploading. When injecting converted configuration into a service, make sure debug switches and internal endpoints are not published along with it. Make the conversion a repeatable pipeline step rather than an occasional manual action: regenerate whenever the source changes, and have the pipeline compare the artifact with what was committed. That keeps artifacts traceable and immediately exposes anyone editing generated output directly. For larger configurations, add a structural validation after conversion, for example checking required fields and types against a schema, so errors fail the build instead of surfacing when the service starts. Validate the output structure on a small configuration first, confirming arrays and date fields match what the consumer expects, before processing the full file. For maintenance, make regeneration mandatory after any source change and add an automated check that rejects a merge when the committed artifact differs from a fresh regeneration. That rule costs almost nothing and eliminates the hardest drift to diagnose, where someone edits only the artifact and not the source, especially on projects where several people maintain one configuration. Attaching the regenerated artifact to the merge request lets reviewers see the real effect of a configuration change instead of reconstructing it themselves. Encode that rule in the commit check and the drift cannot happen.

How It Works Internally

Conversion parses TOML into a tree and serialises it as JSON. Headers make the hierarchy explicit, so the result is usually easy to read; typing needs attention though, since date and time are first-class in TOML but can only be strings in JSON, and the serializer decides whether an offset and milliseconds appear. Numbers may be written in hexadecimal or with underscores in TOML and become plain decimal.

The typing difference
Inputcreated = 2026-10-01T00:00:00Z
Output{"created":"2026-10-01T00:00:00Z"} (only a string is possible in JSON)

Measured on This Page

Fixed: dates truncated to numbers2026-01-01T10:00:00Z starts with digits, and the old order tried numbers first, consuming 2026 and returning — output {"dt": 2026} with the whole time part gone. Date detection now runs before the number branch
Fixed: big integers lost a digit9007199254740993 became …992 through Number. Integers beyond the safe range are now kept verbatim as strings (TOML int64 holds them, JSON numbers do not)
Datetimes and plain datesBoth 2026-01-01T10:00:00Z and 2026-01-01 come through as the original strings with no timezone conversion — the caller decides what to do
Inline tables and arrays{a = 1, b = [1, 2]} becomes a nested object with an array
Multi-line stringsA """ block keeps its line break and appears as a JSON \n escape

Dates are the trap in this direction: 2026-01-01T10:00:00Z opens with digits, and an implementation that tries numeric parsing first happily returns 2026 while discarding the time — a plausible number replacing real data, which nobody notices until a schedule misfires. Recognising date-shaped tokens ahead of the number branch removes it. The second issue is range: a 64-bit TOML integer has more room than the editor's numeric type, so very long values exit as quoted text. Local dates and times are copied verbatim, with no offset guessed on your behalf.

How this was measured: Five TOML snippets (an integer past 2^53, a zoned datetime, a plain date, an inline table with an array, a multi-line string) were converted and each field compared with Python tomllib. Measured before and after the fix. · Measured 2026-10-31

How to Use

  1. Open "TOML to JSON"
  2. Paste TOML with [table] and [[array]] sections
  3. The JSON pane refreshes as you type
  4. Check that table headers became nested objects
  5. Click the copy icon to take the converted JSON

Use Cases

  • Read project metadata — Convert pyproject.toml / Cargo.toml to JSON to extract version, dependencies, etc. via script.
  • Feed configs to APIs — Convert TOML to JSON to submit via REST to services that only accept JSON.
  • Display configs in frontend — Browsers cannot parse TOML natively; convert to JSON for direct rendering.
  • Check types — See how TOML dates, integers, and floats map to JSON types to debug type issues.
  • Diff configs — Convert two TOML files to JSON, then use the JSON Diff tool to compare.
  • Validate schema — Convert TOML to JSON then feed the result into a JSON Schema validator for config validation.
  • CI pipeline variables — Transform a TOML-based local config into JSON for injection into a CI/CD environment block.

FAQ

What do TOML dates become?

Native TOML date-times become ISO 8601 JSON strings, since JSON has no dedicated date type.

How do arrays of tables [[x]] map?

They map to JSON object arrays, i.e. "x": [ {.}, {.} ] — as you would expect.

Does it support all TOML 1.0 features?

It supports mainstream features: inline tables, arrays of tables, multi-line strings, all scalars. Rare edge syntax may need manual tweaks.

Why a duplicate-key error?

TOML forbids redefining a key within the same table. The error points to the conflict — remove the duplicate.

Are inline tables preserved?

An inline table like { a = 1 } is expanded into a plain JSON object {"a":1}; the notation differs but the semantics are identical.

Can I convert to YAML?

Yes, use our TOML to YAML tool.

What happens to [[sections]] in the JSON output?

Arrays-of-tables become JSON arrays of objects, one per section, matching TOML semantics. Repeated sections of the same name merge into one array in document order.

Are TOML dates kept as dates in JSON?

Native TOML datetimes are emitted as RFC 3339 strings because JSON has no date type. Parse them into Date objects on the consumer side; converting in the transform layer introduces timezone ambiguity.