TOML to JSON

Convert TOML configuration files to JSON. Supports arrays of tables, inline tables, and all TOML types.

What Is TOML?

TOML (Tom's Obvious, Minimal Language) is a configuration file format designed to be easy to read and write due to its clear, explicit semantics. Created by Tom Preston-Werner (co-founder of GitHub), TOML maps unambiguously to a hash table and is widely used in the Rust ecosystem (Cargo.toml), Python packaging (pyproject.toml), and static site generators like Hugo.

Unlike YAML, TOML is unambiguous — there is no Norway problem, no implicit type coercion, and no indentation-based structure. This makes it ideal for configuration files that humans write and machines read.

Conversion Example

TOML (Cargo.toml)

toml
[package]
name = "my-app"
version = "0.1.0"
edition = "2021"

[dependencies]
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1", features = ["full"] }

[[bin]]
name = "server"
path = "src/main.rs"

JSON result

json
{
  "package": {
    "name": "my-app",
    "version": "0.1.0",
    "edition": "2021"
  },
  "dependencies": {
    "serde": { "version": "1.0", "features": ["derive"] },
    "tokio": { "version": "1", "features": ["full"] }
  },
  "bin": [
    { "name": "server", "path": "src/main.rs" }
  ]
}

pyproject.toml Example

toml
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "my-package"
version = "1.0.0"
description = "A Python package"
requires-python = ">=3.10"
dependencies = [
  "requests>=2.28",
  "pydantic>=2.0",
]

[project.scripts]
my-cli = "my_package.cli:main"

[tool.ruff]
line-length = 100

pyproject.toml is the standard configuration file for Python packages (PEP 517/518/621). It replaces setup.py, setup.cfg, and requirements.txt for modern Python projects.

TOML Type Mapping to JSON

TOML TypeExampleJSON TypeJSON Example
Stringname = "hello"string"hello"
Integerport = 8080number8080
Floatpi = 3.14159number3.14159
Booleandebug = truebooleantrue
Offset DateTimedt = 1979-05-27T07:32:00Zstring"1979-05-27T07:32:00.000Z"
Local DateTimedt = 1979-05-27T07:32:00string"1979-05-27T07:32:00"
Local Datedate = 1979-05-27string"1979-05-27"
Local Timetime = 07:32:00string"07:32:00"
Arraytags = ["a", "b"]array["a", "b"]
Table[server]object{"server": {}}
Array of Tables[[bins]]array{"bins": [{...}]}
Inline Table{host="localhost"}object{"host": "localhost"}

Common Use Cases

  • Rust Cargo.toml — package metadata, dependencies, build profiles, workspace configuration
  • Python pyproject.toml — project metadata, build system, tool configuration (ruff, black, pytest)
  • Hugo config.toml — static site generator configuration
  • Deno deno.json — Deno runtime and tool configuration
  • Converting to JSON for APIs — when you need to send TOML config data to a JSON API
  • Tooling integrations — some tools require JSON input but your config is TOML

Frequently Asked Questions

This converter uses smol-toml, which supports TOML v1.0.0. This is the current stable TOML specification.

TOML has native date/time types (Offset DateTime, Local DateTime, Local Date, Local Time). Since JSON has no native date type, these are converted to ISO 8601 strings. For example, a TOML date 1979-05-27 becomes the JSON string '1979-05-27'.

TOML arrays of tables ([[bin]] notation) become JSON arrays of objects. Multiple [[bin]] entries are collected into a single array under the 'bin' key.

Yes — use JSONKit's JSON to TOML converter. Note that some JSON structures (arrays at the root level, arrays of mixed types) cannot be directly represented in TOML and will produce an error.

A TOML table ([table]) spans multiple lines and can be extended. An inline table ({key = value}) must fit on one line and cannot be extended. Both map to JSON objects.

Related Tools