You converted a TOML settings file to JSON, opened the result, and something looks wrong. A setting you know you wrote is not at the top level. A date has come out as a plain string. Or the conversion stopped and returned an error instead of a file. In nearly every case, the converter did exactly what the TOML asked; the surprise is how TOML structure maps onto JSON, in four predictable places. This guide works through those four mistakes with the free TOML to JSON Converter on Ovatly, a careful browser parser that converts one way only and reports problems by line number.
Contents
- Quick answer
- How TOML structure maps onto JSON
- Mistake 1: the key that fell into a table
- Mistake 2: dotted keys nest deeper than you remember
- Mistake 3: reading a date string as a conversion bug
- Mistake 4: expecting partial output when the file stops
- How to convert a TOML file, step by step
- Worked example: one small file, three traps
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
Four causes explain almost every TOML to JSON surprise. First, a key written after a [table] header belongs to that table, so it nests inside that table's object instead of the top level. Second, a dotted key builds nesting, so physical.color becomes an object inside an object. Third, dates and times stay strings, because JSON has no date type and the original text is lossless. Fourth, a construct outside the supported subset stops the TOML to JSON Converter completely, with an error naming the line number and no partial output.
How TOML structure maps onto JSON
A TOML file is a flat list of key and value pairs until a header changes the rules. Pairs before any header become the top-level keys of the JSON. A header such as [owner] opens a table: every key after it, until the next header, belongs to that table, which becomes one object under the table's name. Double-bracket headers, such as [[items]], open an array of tables and become an array of objects. Dotted keys build the same nesting in one line: server.tls.enabled = true creates a server object holding a tls object holding enabled.
Values convert by type: strings stay strings, integers and floats become JSON numbers, booleans stay booleans, and dates and times are carried over as text.
Mistake 1: the key that fell into a table
The commonest complaint after a conversion is a missing key, and it is almost never missing: it fell into a table.
[owner]
name = "Ana"
title = "Site"
The writer added title at the end as a document-level setting. But position decides ownership in TOML: title comes after the [owner] header, so it belongs to the owner table, and the JSON shows it nested:
{
"owner": {
"name": "Ana",
"title": "Site"
}
}
Indentation does not rescue you: TOML ignores leading spaces, so an indented key still belongs to the table above it. The fix is mechanical: move the key above the header, or read it from inside the table.
Mistake 2: dotted keys nest deeper than you remember
Dotted keys are a compact way to write structure, and a reliable way to forget you wrote it:
physical.color = "red"
physical.size = "large"
do not create two flat keys. They create one object:
{
"physical": {
"color": "red",
"size": "large"
}
}
Months later, reading the JSON, it is easy to hunt for a top-level color key that never existed. The opposite trap also exists: a quoted key is one key whose name contains the dot, so it stays flat. When a file seems to have invented nesting, search the TOML for dots before blaming the converter.
Mistake 3: reading a date string as a conversion bug
A TOML date such as released = 2024-05-01 comes out of the conversion as the string "2024-05-01". It looks like a downgrade; it is neither a downgrade nor a bug. JSON has no date type: every JSON document carries dates as strings, and each system reading one applies its own parsing. Keeping the original text is lossless: the converter never guesses which format your consumer expects.
The same conservatism applies at the edges of numbers: an integer too large for a normal JSON number, and the float values inf and nan, are kept as their original digit strings instead of being rounded into values JSON cannot represent. If your consumer needs a real date or a big number, it parses that string deliberately, by its own rules.
Mistake 4: expecting partial output when the file stops
The converter is a subset parser. It handles key and value pairs, dotted and quoted keys, tables and arrays of tables, string forms, integers (decimal, hex, octal, binary), floats, booleans, arrays, inline tables, and dates and times as strings. A construct outside that list is not guessed at: the conversion stops, the error names the line number, and no JSON is produced.
That feels harsh until you consider the alternative: a half-converted file that quietly drops its last section can do real damage when something deploys from it. The line number tells you exactly where to look: fix that line, and convert again.
How to convert a TOML file, step by step
- Open the TOML to JSON Converter and paste your TOML in. It runs in your browser, so the file never leaves your device.
- Run the conversion. If it stops, fix the line the error names first; nothing else matters until that line parses.
- Read the output structurally: list the top-level keys, then open each table object and check its keys live where you meant them to.
- Copy the JSON where it is consumed, and keep the TOML as the source you edit.
Worked example: one small file, three traps
Here is the converter's own example, extended slightly:
title = "Site"
[owner]
name = "Ana"
started = 2019-04-12
Converted, it produces:
{
"title": "Site",
"owner": {
"name": "Ana",
"started": "2019-04-12"
}
}
Read it against the mistakes above. Only title is top-level, the only pair before a header. Name sits inside owner, where its position puts it; expect it at the top level and you would report it missing. Started is a string holding the date's original text, because JSON offers no date type. Nothing was lost: the JSON has precisely the structure the TOML describes.
Limitations and honest tradeoffs
The converter works in one direction only, TOML to JSON, so treat the TOML as the document you keep editing.
It is deliberately a subset parser, not a full TOML implementation, which keeps its behaviour predictable and its errors specific, at the cost of stopping on outside constructs. Dates never become native JSON values, because JSON has none; oversized integers and inf and nan are preserved as digit strings a strict consumer may need to handle as text.
Common mistakes
- Hunting for a dropped key at the top level. It is usually nested inside its table. Search the JSON for its name first.
- Trusting indentation. TOML ignores leading spaces; a key indented to look top-level still belongs to the table above it.
- Hand-editing a date string. There is nothing to edit back: JSON cannot hold a date, and the string is correct.
- Re-pasting the same file after an error. The error named a line number. Fix that line, then convert.
- Patching partial output by hand. This converter never produces any; partial files from other tools deserve suspicion.
FAQs
Why is a key missing from the top level of my JSON? It is almost never missing. A key written after a [table] header belongs to that table, so it nests inside that table's object. Search there before assuming the converter dropped it.
Why did my TOML date become a string in the JSON? Because JSON has no date type. The converter keeps dates and times as their original text, exactly as written. That is the correct, lossless behaviour; parse the string into a date where the JSON is consumed.
Why did the conversion stop instead of giving me partial JSON? The converter supports a defined subset of TOML. A construct outside it stops the conversion completely, and the error names the line. No partial output is produced, so you never build on half a file.
What do dotted keys do in the output? Each dot creates a level of nesting: physical.color builds an object named physical holding a key named color. A quoted key is instead one single key whose name contains the dot.
Is my TOML file uploaded to a server? No. The parser runs in your browser, so the file and its JSON never leave your device. Disconnect after the page loads and it still works.
Conclusion
A TOML to JSON result that looks wrong is usually a faithful conversion read with the wrong model. Position decides which table owns a key, dots build nesting, dates travel as strings, and an unsupported line stops the whole conversion with its line number attached. For a complete conversion of a real file, our guide to converting a Rust project's Cargo.toml data into JSON works through a full manifest. More guides in this series live in our Data and JSON Tools guides.
References
- TOML v1.0.0 specification: https://toml.io/en/v1.0.0
- MDN Web Docs, on JSON data types: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON