Convert between TOML and JSON in either direction

Convert TOML and JSON both ways.

Round-trip a small subset of TOML: key-value pairs, [tables], arrays, booleans, numbers, strings, and ISO dates. Pure browser.

TOML

JSON

{
  "title": "Example",
  "published": true,
  "stars": 42,
  "author": {
    "name": "Ada",
    "roles": [
      "dev",
      "ops"
    ]
  }
}

TOML, the config format of Rust and Python projects

TOML stands for Tom's Obvious, Minimal Language, after its creator Tom Preston-Werner, a co-founder of GitHub. It is designed to be read without surprises: every value has an obvious type, and sections are marked with [brackets] like an INI file. Rust's Cargo.toml, Python's pyproject.toml, Hugo sites and many command-line tools use it.

This converter turns TOML into JSON and JSON back into TOML. It covers key-value pairs, [tables], arrays, strings, numbers, booleans and ISO dates.

How to use it

  1. Choose TOML to JSON or JSON to TOML.
  2. Paste the document into the input box.
  3. Read the converted output, or the error message if the input is not valid.
  4. Copy the result.

Example: a top-level key and a table

Input
title = "App"

[server]
port = 8080
hosts = ["a", "b"]
Output
{
  "title": "App",
  "server": {
    "port": 8080,
    "hosts": [
      "a",
      "b"
    ]
  }
}

Everything after [server] belongs to the server table until the next table header starts.

Why TOML instead of YAML or JSON

JSON has no comments and is tedious to edit by hand. YAML is flexible but depends on exact indentation and guesses types from appearance. TOML sits in between: indentation does not matter, strings are always quoted, and true, false and numbers can never be confused with text. A version number like "1.10" stays a string because it has quotes.

The trade-off shows with deep nesting. A five-level structure needs long dotted table names like [tool.poetry.dependencies], which is why TOML is used for configuration rather than for data exchange.

Tables and dotted keys

A table header like [server] opens a section, and every key below it belongs to that section. Dotted names nest: [database.replica] is the replica table inside database. Arrays of tables, written [[products]], create a list of objects, one per header. Keys before the first header live at the top level, which is why title appears first in the example.

Converting JSON to TOML

JSON maps onto TOML as long as the top level is an object, since a TOML document is always a table. Nested objects become table sections and lists become arrays. JSON null has no TOML equivalent, so remove null values or replace them before converting.

Questions

Does it support the whole TOML specification?

It covers the common subset used in configuration files. Inline tables, multi-line strings and some date-time variants may not convert; check unusual files with your language's TOML library.

Are comments preserved?

No. Comments starting with # are dropped, because JSON has nowhere to keep them.

Is my file sent anywhere?

No. Conversion runs in your browser.