TOML ↔ JSON Converter
Exact TOML ⇄ JSON / YAML conversion, with errors that name the rule and the line.
Converted as you type (Ctrl/⌘ + Enter converts now). You can drop a .toml, .json or .yaml file here — it is read on your device, never uploaded.
Warnings
About the TOML ↔ JSON Converter
Turn a TOML file — a Cargo.toml, a pyproject.toml, a Hugo or Netlify config — into JSON or YAML, or write TOML from JSON or YAML. Everything runs in your browser and nothing is rounded: integers keep every digit (9223372036854775807 stays exactly that), floats keep the digits you wrote, and date-times keep their offset and every digit of the fraction (1979-05-27T00:32:00.999999-07:00).
When a TOML file is invalid, you get the rule that was broken and where: "Table [server] is defined twice: it was first defined on line 3", "The dotted key b.c.t cannot add to b.c: it is a table (its [header] is on line 1)…", "Invalid time: the hour is 24, but hours go from 00 to 23". The parser follows TOML 1.1.0 and, on request, the stricter TOML 1.0.0, and it passes every applicable test of the official toml-test suite.
How to use it
- Pick a direction — TOML → JSON, TOML → YAML, JSON → TOML or YAML → TOML — then paste your text, open a file or press Load sample. The result updates as you type.
- For TOML input, keep TOML 1.1.0 or choose TOML 1.0.0 to check that a file also works with parsers that only read 1.0 (Python's
tomllibbefore Python 3.15, for example). - Choose the output options: JSON layout, plain or typed JSON, big integers as strings; YAML indentation; for TOML output, whether date strings become TOML dates, how null is handled and whether small objects become inline tables.
- If there is an error, Jump to error selects it in the editor. Warnings and notes (TOML 1.1 syntax, integers beyond 64 bits, values JSON cannot hold) are listed with their line; Show selects each one.
- Copy or download the result, or press Use as input to convert it back the other way.
Examples
started = 1979-05-27T00:32:00.999999-07:00 id = 9_223_372_036_854_775_807 mode = 0o755
{
"started": "1979-05-27T00:32:00.999999-07:00",
"id": 9223372036854775807,
"mode": 493
}The offset is not turned into UTC and the microseconds are kept. Octal, hexadecimal and binary integers become ordinary decimal numbers.
[server] host = "a" [server] port = 80
Line 4, column 1: Table [server] is defined twice: it was first defined on line 1. A table can be defined only once — move these keys under the first [server] header.
{"package": {"name": "demo", "edition": "2021"}, "bin": [{"name": "a"}, {"name": "b"}]}package = { name = "demo", edition = "2021" }
[[bin]]
name = "a"
[[bin]]
name = "b"Untick Small objects as inline tables to get a [package] section instead.
point = {
x = 1,
y = 2,
}Note: Line breaks or comments inside an inline table are TOML 1.1 syntax. For TOML 1.0 parsers, write the inline table on one line, or use a [table] section.
Common uses
- Reading a
Cargo.toml,pyproject.tomlornetlify.tomlwithjqor a script that only understands JSON. - Moving a configuration between tools that use TOML, JSON or YAML (Hugo accepts all three).
- Finding out exactly why a TOML file is rejected — duplicate keys, a table defined twice, a dotted key that collides with a header.
- Checking that a file avoids TOML 1.1-only syntax before a TOML 1.0 parser reads it.
How TOML values become JSON and YAML
- Strings stay strings; multi-line strings keep their line breaks (a CRLF inside one becomes
\n). - Integers keep every digit at any size;
0x,0oand0bintegers become decimal. JSON readers built on JavaScript'sJSON.parseround integers beyond ±9,007,199,254,740,991, so the converter tells you when there are any and can write them as strings instead. - Floats keep the digits as written (
+1.0becomes1.0,1_000.5becomes1000.5). JSON has noinfornan, so they becomenullwith a warning; YAML writes.infand.nan. - Offset date-times, local date-times, local dates and local times become strings in RFC 3339 form: the offset and the fraction are kept, the separator becomes
T,zbecomesZ, and a time written without seconds (allowed in TOML 1.1) gets:00. In YAML they are written unquoted, so YAML 1.1 parsers such as PyYAML read them as timestamps; local times are quoted because YAML 1.1 reads17:32:00as a number. - Tables, inline tables and arrays of tables become JSON objects and arrays, in the order the keys were written.
Typed JSON writes every value as {"type": …, "value": …}, the format of the toml-test suite, so nothing about the TOML type is lost.
TOML 1.1 and TOML 1.0
TOML 1.1.0 added five things to 1.0.0: line breaks, comments and a trailing comma inside inline tables, the \e escape, the \xHH escape, and times without seconds (07:32). Everything else is the same, so every TOML 1.0 file is also a TOML 1.1 file.
In TOML 1.1.0 mode each use of the new syntax is listed as a note, because parsers that only read TOML 1.0 reject the file — Python's tomllib reads TOML 1.0 up to Python 3.14, for example. In TOML 1.0.0 mode they are errors that tell you the 1.0 way to write them. TOML written by this converter (from JSON or YAML) never uses 1.1-only syntax, so TOML 1.0 parsers can read it too; an integer beyond 64 bits, which many parsers reject, is flagged with a warning.
Rules the converter checks
- A key can be defined only once in a table, and
"key",'key'andkeyare the same key. - A table can be defined only once.
[a.b]implies[a], which can still be defined once later. - Dotted keys (
fruit.color = "red") create tables that cannot get a[header]later, and dotted keys cannot add to a table that has a header — but[fruit.apple.texture]-style sub-tables are allowed. - Inline tables (
{ … }) are complete: nothing can be added to them later. [[name]]cannot add to an array written as a value (name = []), and a key cannot be both a table and an array of tables.- Bare keys use only
A–Z a–z 0–9 _ -; strings must be quoted; numbers have no leading zeros; underscores sit between digits; dates must exist (no 30 February) and times must be valid.
These rules come from the TOML specification and are checked against all of the official toml-test cases.
Writing TOML from JSON or YAML
- TOML has no
null: a null value is an error that names its path, or, with Leave out null values, the key is skipped (nulls inside arrays are always errors, since arrays cannot skip items). - A TOML document is a table, so the JSON or YAML must be an object; a top-level array has to be put under a key first. A YAML stream with several
---documents must be converted one document at a time. - With Dates and times as TOML dates, strings that are exact RFC 3339 dates or times (
2024-03-14,09:30:00,2024-03-14T09:30:00+05:30) become TOML date values. In YAML only unquoted values are converted; quoted ones stay strings. - In each table, plain values come before sub-tables (TOML requires this), so the order of keys can differ from the input; the data is the same.
Limitations
- Comments are not carried over: JSON has none, and comments in YAML input are dropped.
- This is a converter and checker, not a TOML formatter: TOML output is written fresh, without the original comments or layout.
- Integers outside the 64-bit range (−9,223,372,036,854,775,808 to 9,223,372,036,854,775,807) are kept exactly with a warning, but many TOML parsers reject them.
- It checks TOML syntax, not the meaning of a particular file: it does not know which keys Cargo, pip or Hugo expect.
- Tables and arrays nested more than 500 levels deep — counting [headers], dotted keys and inline tables — are refused, in both directions.
Privacy
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.
Frequently asked questions
Is my file uploaded?
No. Parsing and conversion run in your browser, and the page works offline once it has loaded.
Why does my date-time have a T now, or :00 seconds?
JSON has no date type, so dates are written as RFC 3339 strings, which use T between the date and the time and always include seconds. TOML allows a space instead of T and, since TOML 1.1, no seconds; the value is the same. The offset and the fraction of a second are never changed.
Why is null an error when converting to TOML?
TOML has no null value. Remove the key, give it a real value such as an empty string, or tick Leave out null values to skip such keys.
Can it check my Cargo.toml or pyproject.toml?
It checks that the file is valid TOML — the part that tools reject with a parse error — and shows the data as JSON. It does not check the keys each tool expects (for example a missing name in [package]).
Which TOML version is used?
TOML 1.1.0 by default, the current version. Choose TOML 1.0.0 to make the 1.1-only syntax an error — useful when the file is read by a parser that only supports 1.0.