ToolDeck

TOML to JSON

Convert TOML to JSON format

Try an example

TOML Input

JSON Output

Runs locally · Safe to paste secrets
JSON output will appear here…

What is TOML to JSON Conversion?

TOML (Tom's Obvious Minimal Language) is a configuration file format designed for humans. It maps unambiguously to a hash table, supports nested tables, typed values, and inline comments. Many tools and frameworks use TOML as their primary config format: Rust projects rely on Cargo.toml, Python packaging uses pyproject.toml, and Hugo static sites configure via config.toml. Converting TOML to JSON online lets you transform these configuration files into a format that virtually every programming language, API, and data pipeline can consume natively.

JSON (JavaScript Object Notation), defined by RFC 8259, is the most widely supported data interchange format. While TOML prioritizes human readability with its minimal syntax and comment support, JSON prioritizes machine interoperability. A TOML to JSON converter bridges this gap by parsing TOML input according to the TOML v1.0.0 specification and emitting a structurally equivalent JSON document. The conversion preserves all data: strings, integers, floats, booleans, arrays, and tables map directly to their JSON counterparts.

TOML has four native date/time types that JSON cannot represent directly: offset date-times, local date-times, local dates, and local times. JSON has no date type, so these values are serialized as ISO 8601 strings during conversion.

Why Use a TOML to JSON Converter?

Configuration files written in TOML often need to feed into systems that only accept JSON. Rather than rewriting the file by hand or installing a parser library locally, a browser-based converter handles the transformation in seconds.

🔒
Privacy-First Processing
Your TOML data is parsed and converted entirely in the browser. Nothing is uploaded to a server, making it safe to convert configuration files that contain API keys, database credentials, or internal hostnames.
Instant Conversion
Paste your TOML and get formatted JSON output immediately. No need to install Node.js packages, Python libraries, or CLI tools just to perform a one-off format conversion.
🔀
Full TOML v1.0.0 Support
The converter handles all TOML data types including dotted keys, inline tables, arrays of tables, multi-line strings, and date-time values. Edge cases that trip up manual conversion are handled correctly.
📋
No Account Required
Open the page, paste your TOML, and copy the JSON result. There is no sign-up, no rate limit, and no usage tracking. The tool works the same way every time you visit.

TOML to JSON Use Cases

Frontend Development
Convert a Rust WASM project's Cargo.toml metadata into JSON for consumption by a JavaScript build script or a package.json generation step.
Backend Engineering
Transform application config written in TOML into JSON for injection into environments that require JSON config, such as AWS Lambda environment variables or Docker container labels.
DevOps and CI/CD
Pipeline tools like GitHub Actions and GitLab CI often work with JSON inputs. Convert TOML-based tool configurations (rustfmt.toml, taplo.toml) to JSON for linting or validation steps.
QA and Testing
Generate JSON test fixtures from TOML source files. TOML is easier to maintain as a test data source because of its comment support and readable syntax, but test harnesses often expect JSON input.
Data Engineering
When migrating configuration between systems, TOML files from one platform (e.g., InfluxDB, Telegraf) may need to become JSON documents for another platform's API or import tool.
Learning and Education
Students learning data formats can paste TOML examples and see exactly how tables become nested objects, how arrays of tables become JSON arrays, and how TOML's date types map to strings.

TOML to JSON Type Mapping Reference

Every TOML type has a direct JSON equivalent, with one exception: date and time values. The table below shows how each TOML type converts to JSON. This mapping follows the TOML v1.0.0 specification and matches the behavior of standard parsers like tomllib (Python), toml-rs (Rust), and @iarna/toml (Node.js).

TypeTOML SyntaxJSON Output
String"value""value"
Integer4242
Float3.143.14
Booleantrue / falsetrue / false
Offset Date-Time1979-05-27T07:32:00Z"1979-05-27T07:32:00Z"
Local Date-Time1979-05-27T07:32:00"1979-05-27T07:32:00"
Local Date1979-05-27"1979-05-27"
Local Time07:32:00"07:32:00"
Array[1, 2, 3][1, 2, 3]
Table[section]{ "section": {} }
Inline Table{ key = "val" }{ "key": "val" }
Array of Tables[[items]]"items": [{}]

TOML integers support underscores for readability (e.g., 1_000_000) and hexadecimal (0xDEADBEEF), octal (0o755), and binary (0b11010110) literals. All of these convert to plain decimal numbers in JSON. TOML also supports infinity and NaN float values, but these have no JSON representation and will cause a conversion error in strict mode.

Code Examples

Working examples of TOML to JSON conversion in four languages. Each reads a TOML file, parses it, and outputs formatted JSON.

JavaScript (Node.js)
import { parse } from '@iarna/toml'
import fs from 'fs'

const toml = fs.readFileSync('config.toml', 'utf8')
const json = parse(toml)
console.log(JSON.stringify(json, null, 2))
// Input:  [server]
//         host = "localhost"
//         port = 8080
// Output: { "server": { "host": "localhost", "port": 8080 } }
Python
import tomllib   # Python 3.11+ (standard library)
import json

with open('config.toml', 'rb') as f:
    data = tomllib.load(f)

print(json.dumps(data, indent=2, default=str))
# Dates become strings: "1979-05-27"
# Arrays of tables become JSON arrays of objects
Go
package main

import (
    "encoding/json"
    "fmt"
    "os"

    "github.com/BurntSushi/toml"
)

func main() {
    var data map[string]any
    _, err := toml.DecodeFile("config.toml", &data)
    if err != nil {
        panic(err)
    }
    out, _ := json.MarshalIndent(data, "", "  ")
    fmt.Println(string(out))
}
CLI (yj / dasel)
# Using yj (YAML/JSON/TOML converter)
cat config.toml | yj -tj

# Using dasel
dasel -f config.toml -r toml -w json

# Using Python one-liner (3.11+)
python3 -c "import tomllib, json, sys; print(json.dumps(tomllib.load(sys.stdin.buffer), indent=2, default=str))" < config.toml

Frequently Asked Questions

What happens to TOML comments during conversion?
TOML comments (lines starting with #) are discarded during conversion. JSON does not support comments, so there is no way to preserve them in the output. If you need to retain comments, consider using JSONC (JSON with Comments) as your target format instead.
Can TOML to JSON conversion lose data?
For standard TOML documents, no data is lost. All strings, numbers, booleans, arrays, and tables have direct JSON equivalents. The only transformation is date and time values, which become ISO 8601 strings in JSON. Two edge cases can cause issues: TOML supports infinity and NaN floats, which have no JSON representation, and very large integers may exceed JSON parser precision limits (2^53 - 1 in JavaScript).
How are TOML arrays of tables represented in JSON?
TOML's [[double-bracket]] syntax defines an array of tables. Each [[section]] block appends a new object to a JSON array. For example, two [[fruits]] blocks become a JSON array with two objects: "fruits": [{...}, {...}]. The double-bracket syntax is one of the trickier parts of TOML to read cold; the JSON output makes the structure obvious.
Is the conversion reversible? Can I go from JSON back to TOML?
Structurally, yes. Any JSON object can be represented as a TOML table, and JSON arrays map to TOML arrays. However, TOML-specific features like comments, dotted key grouping, and inline table formatting are lost during the initial TOML-to-JSON conversion and cannot be recovered. The round-trip will produce valid but potentially less readable TOML.
What is the difference between TOML and JSON for configuration files?
TOML was designed for configuration: it supports comments, has a more readable syntax for nested structures, distinguishes between integers and floats, and includes native date/time types. JSON was designed for data interchange between programs. JSON is more widely supported by tools and APIs, but TOML is easier for humans to read and edit. Many projects use TOML for source configuration and convert to JSON for deployment.
How does this tool handle dotted keys like server.host?
Dotted keys in TOML (e.g., server.host = "localhost") create nested objects in JSON: {"server": {"host": "localhost"}}. This is equivalent to defining a [server] table with a host key. The converter resolves dotted keys into their full nested structure automatically.
Why does my TOML file fail to convert?
Common causes include: missing quotes around string values (TOML requires them), using tabs for indentation inside multi-line basic strings, duplicate key definitions, and mixing dotted keys with explicit table headers for the same path. The converter displays the parser error message with the line number to help you locate the issue.