Convert TOML to JSON and Back with Full Table Support
TOML, short for Tom's Obvious Minimal Language, has become the configuration format of choice for tools like Cargo, Poetry, and countless CLI utilities because it reads cleanly and maps directly onto a hash table. JSON, meanwhile, is the lingua franca of APIs and JavaScript tooling. Moving between the two by hand is tedious and error-prone, especially once a file uses nested tables or arrays of tables. This converter reads the TOML v1.0.0 subset that real configuration files use and produces the equivalent JSON, and it runs the conversion in reverse so you can turn a JSON object back into idiomatic TOML. All of the work happens in your browser, so a private configuration file with tokens or paths never leaves your device.
The parser understands the constructs that appear in production TOML. A bare key-value pair such as a title assigned a quoted string becomes a top-level property in the JSON object. A table header in square brackets opens a nested object, and a dotted table header creates the corresponding nested structure, so a header written as a parent dot child produces an object inside an object. The double-bracket array-of-tables header is the construct that trips up naive converters: each occurrence appends another element to a JSON array under that key, so two consecutive product blocks become an array containing two objects. Values are typed the way TOML specifies rather than flattened to strings — integers and floats become JSON numbers, true and false become JSON booleans, offset and local datetimes are preserved as strings in their original notation, and both multi-line and single-line arrays become JSON arrays. Inline tables written in curly braces become nested JSON objects on a single line, and any line or trailing segment beginning with a hash is treated as a comment and dropped from the output.
A concrete example shows the mapping clearly. Start with the single line where title is assigned the quoted string TOML Example. The converter emits a JSON object with one property, title, whose value is the string TOML Example. Now add two array-of-tables blocks, each headed by double-bracketed products, the first giving a name and an id and the second giving a different name and id. Because the double-bracket header means append, the converter groups both blocks under a single products key and produces an array holding two objects, each carrying its own name and id. This is exactly the behavior a TOML-aware program expects, and it is the detail that a simple line-by-line translation gets wrong by overwriting the first block with the second. Switch the direction and paste that JSON back in, and the tool regenerates the two double-bracket product blocks along with the top-level title, restoring readable TOML.
The day-to-day uses follow naturally from the two formats living in different ecosystems. A Rust developer can convert a Cargo manifest to JSON to feed it into a script that reads dependency versions programmatically. A Python developer can turn a project configuration file into JSON to inspect it with tooling that only speaks JSON. A DevOps engineer migrating a service between tools can convert a TOML configuration into JSON, adjust it, and convert it back without retyping the structure. During debugging, pasting a TOML file that a program refuses to load often reveals the real problem immediately: a table header that was duplicated, an array of tables that used single brackets instead of double, or a string that was left unquoted where the syntax requires quotes.
A few tips make the conversion reliable. Keep in mind that TOML is strict about types, so a value written without quotes is parsed as a number, boolean, or datetime, and only quoted text becomes a string; if you meant a version like 1.0 to stay a string rather than the float one, wrap it in quotes on the TOML side. When converting JSON back to TOML, remember that JSON has no native date type, so a datetime that started as a TOML value will round-trip as a string unless you keep its original notation. The converter targets the common v1.0.0 subset that configuration files actually use, which covers tables, nested and dotted tables, arrays of tables, inline tables, the standard scalar types, arrays, and comments; extremely rare constructs may not round-trip perfectly, but standard Cargo, Poetry, and CLI configuration files convert cleanly in both directions, and because everything runs locally your data stays on your machine.