📝 TOML ⇔ JSON / YAML Converter
Convert TOML ⇔ JSON and TOML ⇔ YAML in both directions. Ideal for editing Hugo config.toml, Cargo.toml, and pyproject.toml.
🔒 About Privacy
- ・All processing happens entirely in your browser
- ・Your input data is never sent to any server
Copied
📖 Where people get stuck
Converts TOML to JSON or YAML and back again, which is handy for reading through configuration files such as Cargo.toml, pyproject.toml or a Hugo config.toml. Everything runs in the browser. TOML was designed for configuration files that humans write and read by hand, not as an interchange format — which leaves a few gaps between it and JSON or YAML that cannot be closed.
| Case | What happens | What to do |
|---|---|---|
| Some JSON values cannot be converted to TOML | TOML has no null. That is a specification decision rather than an implementation limit, resting on the view that in a configuration file, no value should be expressed by not writing the key. So {"timeout": null} has no TOML representation. For related reasons, arrays of mixed type such as [1, "two", true] are rejected by many implementations — TOML 1.0 permits them, but parser support is uneven. Trying to convert an API response directly into TOML runs into these two first. |
Strip null keys before converting — that is the response consistent with TOML design philosophy. If you want to state the absence explicitly, put in a default that means something for that key, such as an empty string or false. Better still, do not use TOML for interchange at all: it is for a different job. TOML suits configuration that people edit by hand and review as a diff, while machine-generated, machine-read data belongs in JSON. If a structure feels awkward to express in TOML, that may be a signal that it is too complex to be configuration — beyond three levels of nesting, the design is worth revisiting. |
| The output looks different from the hand-written original | TOML can express the same data in three different ways: a table header [server], an array of tables [[bin]], and an inline table { host = "x", port = 80 }. A converter picks one of them, so the output can look nothing like what you wrote by hand even though the structure is identical. The usual source of confusion is that table headers work by position: every key after [server] belongs to server. Line order carries meaning, so moving a key one line changes which table it belongs to. |
Every one of those outputs is valid TOML — if you want it to match the hand-written style, take the conversion as a starting point and tidy it by hand. And do not round-trip an existing configuration file through this tool, for one decisive reason: the comments are lost completely. JSON has no concept of a comment, so reformatting Cargo.toml or pyproject.toml via JSON throws away the most valuable information in the file, such as why a dependency is pinned. Use this tool to read a file, and make your edits directly in the original. |
| Dates become strings, or strings become dates | TOML has date and time as first-class types: created = 1979-05-27T07:32:00Z is written without quotes and is a datetime value, not a string. JSON has no such type, so conversion turns it into an ISO 8601 string — a natural enough translation. The reverse direction is the problem: converting JSON "2024-01-01" back to TOML can, depending on the implementation, drop the quotes and produce a date value, changing the meaning. If you are handling version dates, or identifiers that merely look like dates, such as a release named "2024-01-01", a round trip alone changes the type. |
Do not round-trip values that look like dates. Where you have no choice, read the converted TOML and check that the quotes are on the side you intended: created = 2024-01-01 is a date and created = "2024-01-01" is a string, and that one pair of quotes decides the type. To avoid the question at design time, prefix values that must not be dates, as in "v2024-01-01". TOML has three temporal types — local date, local time and offset date-time — and they mean different things; always write the offset on values that need a time zone. |
Configuration files carry conventions, not just structure. The keys in pyproject.toml are fixed by PEP 518 and PEP 621, and changing the shape of [project] or [build-system] makes pip install -e . fail. The same holds for Cargo.toml: [[bin]] must be an array of tables, and writing [bin] means something else entirely. So this tool is properly used for reading and understanding a configuration file someone else wrote, not as a route for reformatting or rewriting one. Second, TOML has no anchors or references the way YAML does. You have to repeat a value in several places, which can look redundant, but it is the consequence of a design decision that a configuration file should be understandable read straight down. If you want to factor something out, do not try to solve it inside the TOML — solve it in whatever generates the file.
📖 How to Use
-
1
Paste TOMLPaste TOML on the left or pick a sample (Hugo / Cargo / pyproject).
-
2
Pick the target formatPick JSON or YAML. For JSON, choose 2/4 spaces or minify.
-
3
Convert both directionsResults appear on the right. Reverse direction (JSON/YAML → TOML) updates live too.
❓ Frequently Asked Questions
What is TOML?
How are dates and times handled?
Can I convert YAML or JSON back to TOML?
🔗 Related Tools
🐛 Found a bug or issue with this tool?
Free to use, no signup. Even just the steps to reproduce are helpful. Reports go directly to the operator and help us fix issues.
Thanks for your report!
Your report has been delivered to the operator and will be used to improve the tool.