Tools

TOML → JSON

Convert TOML data to JSON format.

TOML
Ln:1 Col:1
JSON

About TOML to JSON Conversion

TOML (Tom's Obvious, Minimal Language) is a configuration file format designed to be easy to read and write. It is used by Cargo (Rust), pyproject.toml (Python), Hugo, and many other tools. Converting TOML to JSON is useful when you need to process configuration data programmatically, integrate with JSON-based APIs, or migrate between configuration formats.

TOML Format Overview

TOML supports key-value pairs, strings (basic with escapes and literal without), integers, floats, booleans, dates/times, arrays, and tables (sections). Tables are defined with [section] headers and can be nested using dot notation ([servers.alpha]). Array of tables use double brackets ([[products]]).

TOML is designed to map unambiguously to a hash table. Unlike YAML, TOML has no significant whitespace — indentation is purely cosmetic. Keys are bare by default but can be quoted for special characters. Comments start with # and run to end of line. TOML's strict typing prevents the implicit type coercion issues found in YAML.

Frequently Asked Questions

What are the main differences between TOML and JSON?
TOML supports comments, has native date/time types, allows trailing commas, and uses sections instead of deeply nested objects. JSON is more widely supported by APIs and databases but lacks comments and readability features.
How are TOML tables converted to JSON?
TOML tables ([section]) become JSON objects. Dotted keys like [servers.alpha] create nested objects: {"servers": {"alpha": {...}}}. Array of tables ([[items]]) become JSON arrays of objects.
Are TOML dates preserved in JSON?
TOML dates and times are converted to their string representation in JSON, since JSON has no native date type. The original TOML format (e.g., 2024-01-15T10:30:00Z) is preserved as a string.