TOML to JSON

Convert TOML documents into JSON with configurable indentation and compact-mode output.

Convert TOML documents into JSON with configurable indentation and compact-mode output. Convert TOML documents into JSON with configurable indentation and compact-mode output.

Output

Background

Why you might want TOML as JSON

JSON is the lingua franca of the web: every API speaks it, every editor can highlight it, and every language has a parser in its standard library. TOML excels at human-edited configuration but is less universally supported as a runtime data exchange format. When you need to feed a TOML config into a tool that only consumes JSON (web playgrounds, schema validators, code generators, etc.), a reliable TOML-to-JSON converter saves the day.

The conversion is mostly lossless because both formats are expressive enough to represent the same primitives. The few TOML-specific types (multi-line strings, dates) translate to plain strings; the few JSON-specific values (null) translate to the JSON literal null, which TOML has no native equivalent of.

Features worth knowing

The converter offers a pretty-print toggle (with 2/4-space indentation) and a compact mode (single line). For very large config files, the compact output is much easier to paste into a curl request body. The swap button moves the JSON output back into the input box so you can re-edit and re-export as TOML again.

Workflow tips

After conversion, validate the JSON with a schema validator (ajv, jsonschema) before pushing it to a downstream tool. The TOML parser is strict: it will reject unquoted scalars that start with digits, inline tables with comments, and other common mistakes. Use the error messages to fix the source document, not the JSON.

Practical example

Suppose you maintain a pyproject.toml snippet that lists your tool's runtime configuration under [tool.beetools]. To feed the same configuration into a JavaScript build pipeline that only accepts JSON, run the snippet through this converter. The output preserves the table hierarchy, so a nested block like [tool.beetools.cache] becomes { "tool": { "beetools": { "cache": { ... } } } }. Dotted keys collapse into nested objects on the way out, mirroring how the TOML parser initially built them. Once you have the JSON, validate it with ajv or jsonschema before passing it downstream -- the converter only translates syntax.

Built in-house. TOML is parsed with the BSD-3 smol-toml library bundled in public/assets, then emitted as JSON via native JSON.stringify. No upload happens.

Frequently asked questions

Does the converter support TOML 1.0 features?
Yes. The converter parses TOML 1.0, including arrays of tables (`[[name]]`), inline tables (`{ key = "value" }`), and dotted keys (`a.b.c`).
How are TOML dates emitted in JSON?
Dates without a time component become JSON strings in `YYYY-MM-DD` form. Datetimes become `YYYY-MM-DDTHH:MM:SS[.fraction][Z|+offset]`. The receiving JSON consumer can parse them with their language's date library.
What about TOML multi-line strings?
They are emitted as regular JSON strings with embedded newline characters. JSON cannot preserve the exact literal-style, but the parsed value is identical.
Can the converter handle dotted keys?
Yes. `a.b.c = 1` becomes `{ "a": { "b": { "c": 1 } } }`. The converter expands every dotted key into nested objects.
Will the converter reject invalid TOML?
Yes. The parser raises an error with a line/column pointer at the first invalid token. Fix the source TOML and try again.
Is my TOML uploaded?
No. Parsing happens locally via the bundled smol-toml library; nothing leaves the browser.