How to convert JSON to TOML
- Paste a JSON object or open a file. The TOML appears as you type.
- Check the note under the output: it says when values were left out.
- Press ⇄ to check the round trip in TOML to JSON.
Invalid JSON shows its line and column; the JSON validator explains the message.
Example: a Hugo site config
{
"baseURL": "https://example.org/",
"title": "Field Notes",
"draft": null,
"params": { "author": "R. Okafor", "showToc": true, "ratio": 1.0 },
"menu": {
"main": [
{ "name": "Posts", "url": "/posts/", "weight": 1 },
{ "name": "About", "url": "/about/", "weight": 2 }
]
}
}
baseURL = "https://example.org/"
title = "Field Notes"
[params]
author = "R. Okafor"
showToc = true
ratio = 1
[[menu.main]]
name = "Posts"
url = "/posts/"
weight = 1
[[menu.main]]
name = "About"
url = "/about/"
weight = 2
The note TOML has no null. 1 null value was left out. refers to draft.
How JSON maps to TOML
- Plain values come first, then each nested object becomes a table named by its path, such as
[params]or[server.http]. - Arrays of objects become arrays of tables: one
[[menu.main]]block per item. - Arrays of plain values stay inline:
regions = [ "eu-north-1", "eu-west-1" ]. - Keys with spaces or dots are quoted (
"dotted.key" = 2) so they are not read as nested tables. nullhas no TOML form, so the key is left out and counted in the note.- Whole numbers become integers:
1.0becameratio = 1. Add the.0back if the reader wants a float.
The top level must be an object
A JSON array or a single value cannot be a TOML document. The tool answers TOML needs an object at the top level. and, for an array, suggests wrapping it: {"items": [...]} gives one [[items]] block per item.
For Kubernetes or Docker Compose files, use JSON to YAML instead.