TOML ⇄ JSON Converter
Convert TOML configuration to JSON and back in your browser. Handles tables, nested keys, arrays and the usual scalar types, with selectable indentation.
Convert TOML into JSON to see the structure a configuration file actually describes, or convert JSON into TOML when a tool expects that format. Tables, dotted keys, arrays and the standard scalar types are all handled.
Paste some TOML...
// TOML ⇄ JSON Converter: Features
TOML looks flat and is not
The format's strength is that it reads like an INI file while describing nested data. A table header in square brackets opens a section, a dotted key nests further, and an array of tables repeats a structure. The consequence is that the nesting is implied rather than visible, and a section header in the wrong place silently reparents everything beneath it. Converting to JSON makes the resulting tree explicit, which is usually the fastest way to confirm a file means what you think.
Where you meet it
Rust uses TOML for Cargo.toml, Python has adopted it for pyproject.toml and the packaging ecosystem built on it, Hugo and several other static site generators use it for configuration, and many Go and Node tools accept it. Its appeal for configuration is that it has comments, unambiguous types and no significant whitespace, which removes the class of problems that indentation-based formats introduce.
JSON to TOML needs an object at the top
TOML documents are always a table at the root, so there is no way to express a top-level array or a bare scalar. Converting JSON that starts with an array or a primitive value is therefore refused with an explicit message rather than producing something misleading. Wrap the value in an object with a named key and the conversion succeeds.
Types are explicit, which is the point
Unlike YAML, TOML does not guess. A string is quoted, a number is written as a number, a boolean is true or false in lower case, and dates and times have their own literal syntax taken from RFC 3339. That explicitness is why a version string stays a string and a country code stays a country code, and it removes an entire family of configuration bugs that indentation-based formats are prone to.
Dependency manifests stay on your machine
Parsing and serialisation run in your browser and nothing is transmitted, stored or logged, so build configuration, dependency manifests and files containing internal hostnames are all safe to paste. For the other common configuration formats, the YAML converter works the same way, and the JSON Formatter will tidy the output.
// TOML ⇄ JSON Converter: FAQ
What is TOML for?
- It is a configuration format designed to be obvious to read and unambiguous to parse. It supports comments, has explicit types, and maps cleanly onto a hash table, which makes it a good fit for files that people edit by hand and machines consume. Cargo.toml and pyproject.toml are the best known examples.
Why convert TOML to JSON?
- Mostly to see the structure. Table headers and dotted keys describe nesting without showing it, so converting to JSON reveals the tree you have actually written. The other reason is interoperability: plenty of tooling accepts JSON and not TOML.
Why can I not convert my JSON array to TOML?
- Because a TOML document is a table at the root, so a top-level array or a bare value has no valid representation. Wrap it in an object, for example turning the array into the value of a key named items, and the conversion will work.
How are nested tables represented?
- A header such as a section name containing dots creates nested objects in the JSON output, and an array of tables, written with double square brackets, becomes an array of objects. Converting in the other direction produces the corresponding TOML headers.
Does it keep comments?
- No. JSON has no comment syntax, so comments are lost when converting to TOML output's source or into JSON. Convert for inspection or for feeding another tool, and keep the commented original as the file you edit.
How are dates handled?
- TOML has first-class date, time and date-time literals based on RFC 3339. JSON has no date type, so those values become strings when converted. Converting back turns the string into a string rather than restoring the date literal, which is a limitation of JSON rather than of the converter.
How does TOML compare with YAML for configuration?
- TOML is stricter and more predictable: explicit types, no significant whitespace, and no anchors or aliases. YAML is more expressive and handles deeply nested structures and multi-line strings more gracefully. For flat-to-moderately-nested configuration TOML tends to cause fewer surprises; for deeply nested documents such as Kubernetes manifests YAML remains more practical.
What happens to a duplicate key?
- TOML forbids defining the same key twice, and a parser is expected to reject it. If your file is accepted elsewhere but fails here, check for a key defined both at the top level and inside a table with a dotted name, which is an easy duplication to miss.
Is it safe to paste a dependency manifest?
- Yes. The conversion runs in your browser, and the file is never transmitted, stored or logged. Internal registry URLs and private package names stay on your machine.
Is the configuration I paste sent to a server?
- No. Everything happens in the page, and closing the tab discards whatever you pasted.
// How to Use TOML ⇄ JSON Converter
-
TOML to JSON, or JSON to TOML
Select TOML to JSON or JSON to TOML. SWAP moves the current output into the input and flips the direction, which is useful for checking a round trip.
-
Paste your configuration
Put the TOML or JSON into the input box. Conversion happens as you type, and problems such as a top-level array in JSON to TOML mode are reported with a message explaining what is required.
-
Set the indentation and copy the config
Choose the indentation for JSON output and copy the result with one click. For inspection, reading the JSON tree is usually the quickest way to confirm the nesting is what you intended.
Category Data Formats