TOML, JSON and YAML: what a conversion loses
TOML, JSON and YAML all describe data as keys and values, but their type systems are not the same. A conversion is not a copy: it takes each type and finds the nearest shape the other format can express. That is why a round trip does not always return the original document.
What only TOML has
- Date and time types: offset date-time, local date-time, local date, local time. Neither JSON nor the YAML core schema has them.
- Comments: a
#comment has nowhere to go in JSON or YAML. - The array-of-tables notation:
[[a]]becomes an array of objects in JSON and a sequence in YAML. - 64-bit integers: JSON does not specify number precision, so large integers can be read as floats.
What only JSON has: null
TOML has no null. When a JSON or YAML document contains null, there is no way to carry it into TOML. This tool skips the key and shows a warning. Replacing it with an empty string changes the meaning, and replacing it with 0 is worse. Better to remove the null or change the design that produced it.
{"retry": null} -> # the retry key cannot be written (warning)
Dates become strings
TOML date-times become ISO 8601 strings in JSON and YAML. Coming back, this tool does not reinterpret strings as dates, because "2026-11-30" could be a date or a postcode. Set the type by hand after conversion when it matters.
Big integers and floats
JSON numbers do not distinguish integers from floats. Read in JavaScript, an integer beyond 2^53 loses precision. This tool preserves integer literals and carries them to TOML, but beyond the TOML 64-bit range it writes a string and warns. In the other direction, TOML's 1.0 is 1.0 in JSON, yet some languages read it back as the integer 1.
YAML traps
In YAML the same text can have different types depending on context. yes, no, on and off were booleans in YAML 1.1 and are strings in YAML 1.2. Parsers also disagree about 1.0 and 1e3. This tool follows the YAML 1.2 core schema, and refuses anchors, aliases, tags and multiple documents with a clear error instead of guessing.
Checking a round trip
- Paste TOML and look at the JSON tab. Check whether dates became strings and whether null disappeared.
- Switch the input format to JSON, paste the JSON result and read the TOML tab. Compare key order and types with the original.
- Turn on key sorting and re-run to remove ordering differences. Comments will not return either way.
- Download the diagnostic report to keep the conversion notes and the type list together.
The conversion moves syntax and structure; it does not validate a schema. Converting Cargo.toml to JSON says nothing about whether Cargo will accept the file.
Which format to choose
- Settings people edit often: TOML, which keeps comments and date types.
- Exchange between programs: JSON, with simple types that almost every language reads by default.
- Deployment files heavy on multi-line text and lists: YAML, but quote values explicitly because parsers differ.
Questions
Can comments be restored after conversion?
This tool does not put comments in the result. Keep the original TOML when comments matter and move only values.
How do I keep a date as a date?
JSON and YAML have no date type, so a string is the limit. When converting back to TOML, set the type yourself or record it in a schema.
Why are YAML anchors an error?
Anchors and aliases reuse values within a document and cannot be expanded safely by a simple tree conversion. This tool says it does not support them rather than produce something quietly wrong.
Move the same document between the JSON, YAML and TOML tabs and watch what changes.
Open the toolThese guides follow the TOML v1.0.0 specification (2021-01-11), RFC 3339 (dates and times), the YAML 1.2 core schema and JSON (RFC 8259). Every example is synthetic.