Skip to content

JSON to TOML Converter

Paste JSON, get TOML instantly in your browser. Safe null handling, top-level table checks, Cargo.toml & pyproject.toml-ready output. 100% private, no upload.

No Tracking Runs in Browser Free
0 chars
TOML Output
0 lines
Reviewed for TOML 1.0.0 spec compliance, top-level table enforcement, and transparent null handling — Go Tools Engineering Team · Jul 2, 2026

What is TOML and Why Convert from JSON?

TOML (Tom's Obvious, Minimal Language) is a configuration file format built to be unambiguous and easy for humans to read and edit. It is the standard config format for the Rust ecosystem (Cargo.toml), modern Python packaging (pyproject.toml), and tools like Hugo, Netlify, Poetry, and Foundry. JSON is the universal machine format that tools and APIs produce. Converting JSON to TOML is common when you have structured data as JSON but need a human-editable TOML config as the destination — generating a Cargo.toml or pyproject.toml, or turning an application's JSON settings into a readable config file.

TOML is more structured than JSON, and this tool turns that strictness into guidance rather than cryptic failures:

**1. Top-level table enforcement.** Every TOML document is a table at the root — a bare array or scalar is not valid TOML. Instead of emitting broken output for { top-level array } input, this tool detects it and tells you exactly how to wrap your data under a key, so you always get valid TOML or a clear explanation.

**2. Safe, transparent null handling.** JSON has null; TOML does not. Most converters either crash or silently discard data. This tool is explicit: object keys with null values are dropped and the removed keys are listed in a warning, and a null inside an array — which has no valid TOML representation — produces a precise, path-pointing error. You are never surprised by missing data.

**3. Idiomatic TOML output.** Nested objects become [tables], deeply nested objects become dotted tables ([tool.ruff]), and arrays of objects become arrays of tables ([[section]]) — the shape real Cargo.toml and pyproject.toml files use. The conversion is powered by the zero-dependency, TOML 1.0.0-compliant smol-toml library.

**4. 100% browser-based privacy.** Your JSON — which may contain credentials, tokens, or internal service details — never leaves your browser. No upload, no server, no logging. Confirm it in your browser's Network tab.

Need the reverse? Use the TOML to JSON Converter. Working with other config formats? Try the JSON to YAML Converter and YAML to JSON Converter, or clean up your JSON input first with the JSON Formatter. Each format has its niche: JSON for machine interchange, TOML for human-edited application and tooling config, and YAML for deeply nested infrastructure manifests. This converter lets you move from JSON to TOML without writing any code.

// Convert JSON to TOML in Node.js using the smol-toml library
import { stringify } from 'smol-toml';

const data = JSON.parse(`{
  "package": { "name": "my-app", "version": "1.0.0" },
  "dependencies": { "serde": { "version": "1.0" } }
}`);

// The top-level value must be an object; null values on objects are dropped.
const toml = stringify(data);

console.log(toml);
// [package]
// name = "my-app"
// version = "1.0.0"
//
// [dependencies.serde]
// version = "1.0"

Key Features

Live Conversion

TOML output updates instantly as you type or paste JSON — no Convert button needed. Large inputs (>200KB) automatically switch to manual mode to keep the browser responsive.

Top-Level Table Guidance

TOML documents must be a table at the root. If your JSON top level is an array or scalar, the tool tells you exactly how to wrap it under a key — no broken output, no guesswork.

Safe Null Handling

TOML has no null. Object keys with null values are dropped and listed in a warning; a null inside an array raises a precise, path-pointing error. You always know what happened to your data.

Idiomatic TOML Output

Nested objects become [tables], deeply nested objects become dotted tables ([tool.ruff]), and arrays of objects become arrays of tables ([[section]]) — the shape real Cargo.toml and pyproject.toml use.

Float and Integer Awareness

TOML separates integers from floats, so a float like 1.0 is written as the integer 1. The tool warns you when this coercion changes a value's type, so round-trip surprises are visible.

100% Browser-Based Privacy

All parsing runs locally in your browser. Your JSON — including credentials, tokens, and internal service details — is never uploaded, stored, or logged.

Examples

Cargo.toml source

{
  "package": {
    "name": "my-app",
    "version": "1.0.0",
    "edition": "2021"
  },
  "dependencies": {
    "serde": { "version": "1.0", "features": ["derive"] },
    "tokio": { "version": "1", "features": ["full"] }
  }
}

Generate a Rust Cargo.toml from JSON — nested objects become [tables] and inline objects become inline tables, exactly as Cargo expects.

pyproject.toml source

{
  "build-system": {
    "requires": ["hatchling"],
    "build-backend": "hatchling.build"
  },
  "project": {
    "name": "my-package",
    "version": "0.3.1",
    "requires-python": ">=3.10",
    "dependencies": ["requests>=2.31", "pydantic>=2.0"]
  }
}

Generate a PEP 621 pyproject.toml from JSON project metadata — useful when a tool or API produces JSON that you need in TOML form.

App settings

{
  "title": "My Service",
  "debug": false,
  "port": 8080,
  "database": {
    "host": "localhost",
    "port": 5432,
    "pool_size": 10
  },
  "features": ["auth", "metrics", "tracing"]
}

Convert a flat application settings object to TOML — top-level scalars stay at the top and the nested database object becomes a [database] table.

Servers (array of tables)

{
  "servers": [
    { "name": "alpha", "ip": "10.0.0.1", "ports": [8001, 8002] },
    { "name": "beta", "ip": "10.0.0.2", "ports": [9001] }
  ]
}

An array of objects becomes an array of tables ([[servers]]) in TOML — the idiomatic way to express repeated sections.

Netlify config source

{
  "build": {
    "command": "npm run build",
    "publish": "dist",
    "environment": { "NODE_VERSION": "20" }
  },
  "redirects": [
    { "from": "/old", "to": "/new", "status": 301, "force": true }
  ]
}

Turn a JSON deployment config into netlify.toml, with nested [build] and [build.environment] tables and a [[redirects]] array of tables.

Config with dotted structure

{
  "tool": {
    "ruff": { "line-length": 100, "target-version": "py310" },
    "black": { "line-length": 100 }
  }
}

Deeply nested JSON objects become dotted TOML tables like [tool.ruff] and [tool.black] — the shape pyproject.toml tooling expects.

How to Use

  1. 1

    Paste Your JSON

    Enter or paste your JSON into the input field above. You can also click 'Load example' to try a Cargo.toml source, pyproject.toml source, or app settings object.

  2. 2

    See Live TOML Output

    TOML appears instantly in the output panel. If your JSON has a top-level array or null values, the tool explains exactly what to do rather than producing broken output.

  3. 3

    Copy or Download

    Click Copy to grab the TOML to your clipboard, or Download to save it as a .toml file ready for Cargo, Poetry, Hugo, Netlify, or any tool that reads TOML.

Common JSON-to-TOML Pitfalls

Top-Level Array or Scalar

TOML documents must be a table (object) at the root. A JSON array or lone value cannot be a TOML document. Wrap it under a key to convert it.

✗ Wrong
[1, 2, 3]
✓ Correct
{ "items": [1, 2, 3] }

Null Values in Objects

TOML has no null type, so an object key with a null value is dropped during conversion. The tool warns you which keys were removed. If you need to keep the key, give it a real value or an empty string.

✗ Wrong
{ "name": "a", "nickname": null }
✓ Correct
{ "name": "a", "nickname": "" }

Null Inside an Array

A TOML array cannot contain a null or a gap, so JSON like [1, null, 3] has no valid TOML output. Remove the null or replace it with a real value before converting.

✗ Wrong
{ "ports": [8001, null, 8003] }
✓ Correct
{ "ports": [8001, 8003] }

Invalid JSON Syntax

The input must be valid JSON first. Trailing commas, single quotes, and unquoted keys are common mistakes copied from JavaScript that are not valid JSON and must be fixed before converting.

✗ Wrong
{ 'name': 'a', 'active': true, }
✓ Correct
{ "name": "a", "active": true }

Float with Zero Fraction Becomes Integer

TOML writes a float whose fractional part is zero (1.0) as the integer 1, changing its type on a round-trip. The tool warns you. If the value is conceptually an integer, this is fine; if it must stay a float, TOML cannot preserve that for whole numbers.

✗ Wrong
{ "ratio": 1.0 }  →  ratio = 1
✓ Correct
{ "ratio": 1.5 }  →  ratio = 1.5

Mixing Object and Array at the Same Key

A JSON key must be consistently an object or an array to map to a table or array of tables. Inconsistent shapes across a dataset can produce confusing TOML — normalize the structure first.

✗ Wrong
{ "server": { "a": 1 }, "server": [1] }
✓ Correct
{ "server": { "a": 1 }, "servers": [1] }

Common Use Cases

Generate Cargo.toml
Turn structured JSON — from a scaffolding tool, an API, or a script — into a valid Rust Cargo.toml, with nested [dependencies] tables and inline tables produced automatically.
Generate pyproject.toml
Convert JSON project metadata into a PEP 621 pyproject.toml, including dotted [tool.*] tables, so tooling that emits JSON can produce Python packaging config.
Human-Editable Config from JSON
Transform an application's JSON settings into a readable TOML config file that humans can comfortably edit, with comments added afterward by hand.
Deployment Config Generation
Produce netlify.toml, foundry.toml, or similar platform configs from JSON, turning nested objects and arrays of objects into the tables and arrays of tables those tools expect.
Config Format Migration
Move configuration from a JSON-based system to a TOML-based one, using this converter as the bridge and the null and top-level warnings to catch anything that will not map.
Prototyping TOML Structure
Sketch a config as JSON — a format most developers type fluently — then convert to TOML to see the idiomatic table and array-of-tables layout before committing it to a repo.

Technical Details

RFC 8259 JSON Parsing
JSON input is parsed with the browser's native JSON.parse(), which is fully RFC 8259 compliant. Before serialization, the tool checks that the top-level value is an object and scans for null values so it can warn about dropped object keys or reject a null inside an array with a precise path.
TOML 1.0.0 Output via smol-toml
TOML is generated with the smol-toml library, a zero-dependency, fully TOML 1.0.0-compliant serializer. Nested objects become tables, deeply nested objects become dotted tables, and arrays of objects become arrays of tables. Floats with a zero fractional part are written as integers per TOML rules, with a warning.
100% Browser-Based — No Upload, No Server
All processing happens in your browser's JavaScript engine. No data is transmitted at any point. Inputs larger than 200KB switch from live to manual mode (an explicit Convert click) to keep the interface responsive.

Best Practices

Wrap Top-Level Arrays Under a Key
If your data is naturally a JSON array, wrap it in an object with a descriptive key ({ "items": [...] }) before converting. TOML documents must be a table at the root, and the key gives your array a clear name in the output.
Decide What Nulls Should Mean
Before converting, decide whether a null field should disappear (drop the key) or carry a value. TOML will drop object nulls and reject array nulls, so resolving them in your JSON first gives predictable, complete output.
Use Nested Objects for Grouping
Group related settings into nested objects in your JSON — they become clean [tables] and dotted tables in TOML, which is far more readable than a flat list of keys, matching how Cargo and pyproject configs are organized.
Validate Your JSON First
If your JSON is hand-written or comes from an unreliable source, validate it with our JSON Formatter to catch trailing commas and quoting mistakes before converting to TOML.
Add Comments After Converting
JSON has no comments, so none carry over. Since TOML supports # comments, add documentation to the generated TOML by hand — one of the main reasons to move human-edited config to TOML in the first place.

Frequently Asked Questions

How do I convert JSON to TOML online?
Paste your JSON into the input field above. The tool parses it and produces TOML instantly in your browser — no button click needed. Once the TOML appears in the output area, click Copy to grab it to your clipboard or Download to save it as a .toml file. Everything runs locally, so your JSON never leaves your device. Two things to know before you start: your JSON's top level must be an object (not an array), and null values have no TOML equivalent — the tool explains both clearly if they come up.
What is TOML and why convert JSON to it?
TOML (Tom's Obvious, Minimal Language) is a configuration format designed to be easy for humans to read and write, with unambiguous semantics. It is the config format for Rust's Cargo, Python's pyproject.toml, Hugo, Netlify, Poetry, and more. You convert JSON to TOML when a tool or API gives you JSON but the destination expects TOML — for example, generating a Cargo.toml or pyproject.toml from structured data, or turning an application's JSON settings into a human-editable TOML config file.
Why must the top level of my JSON be an object?
TOML documents are always a table (a set of key-value pairs) at the root — the specification does not allow a bare array, string, or number at the top level. So a JSON array like [1, 2, 3] or a lone value like 42 cannot be converted directly. The fix is to wrap it under a key: { "items": [1, 2, 3] } converts cleanly to items = [1, 2, 3]. This tool detects a non-object top level and tells you exactly how to wrap it, instead of producing broken output.
What happens to null values when converting JSON to TOML?
TOML has no null type, so null cannot be represented. This tool handles it safely and transparently in two ways. When a null appears as an object value, TOML simply omits that key — and the tool shows a warning listing exactly which keys were dropped, so you are never surprised by silent data loss. When a null appears inside an array, there is no valid TOML output at all (an array cannot hold a gap), so the tool reports an error pointing at the exact path of the offending null. Either way, you know precisely what happened and where.
How are nested objects and arrays converted to TOML?
A nested JSON object becomes a TOML table: { "owner": { "name": "Tom" } } becomes [owner] with name = "Tom". Deeply nested objects become dotted tables like [tool.ruff]. An array of objects becomes an array of tables written with double brackets ([[servers]]), which is the idiomatic TOML way to express repeated sections. Arrays of scalars stay inline as arrays (ports = [8001, 8002]). The output follows the TOML 1.0.0 specification.
What happens to floating-point numbers like 1.0?
TOML distinguishes integers from floats, and a float whose fractional part is zero (like 1.0) is written as the integer 1. So { "version": 1.0 } becomes version = 1. The tool shows a small warning when this coercion happens, because it changes the value's type on a round-trip. If you need the value to stay a float, that distinction cannot be preserved through TOML for whole numbers — consider whether an integer is actually what you want.
Is my JSON data sent to any server?
No. All parsing and conversion happen entirely in your browser using JavaScript. Your JSON is never uploaded, never stored, and never logged. This makes the tool safe for configuration that contains API keys, database credentials, or internal service details. You can verify this by opening your browser's Network tab — pasting JSON triggers zero network requests.
Can I convert TOML back to JSON?
Yes. Use the companion TOML to JSON Converter for the reverse direction, or click the Swap direction button at the top of this tool to flip the input and output in place. TOML to JSON has fewer constraints — it accepts any valid TOML — so round-tripping JSON → TOML → JSON is reliable as long as your JSON had no nulls or top-level array to begin with.
How do I convert JSON to TOML on the command line?
A popular option is the Go tool 'yj' (yj -jt reads JSON and writes TOML). In Python you can use the third-party 'tomli-w' package: import json, tomli_w; tomli_w.dump(json.load(open('config.json')), open('config.toml','wb')). In Node.js: import { stringify } from 'smol-toml'; const toml = stringify(JSON.parse(text)) — the same library this tool uses. For a quick one-off without installing anything, this browser tool is the fastest path.
How do I convert JSON to TOML in Python, Rust, or Node.js?
In Python: import json, tomli_w; tomli_w.dump(json.load(open('config.json')), open('config.toml','wb')). In Rust: use serde_json and toml — let value: serde_json::Value = serde_json::from_str(&text)?; let toml = toml::to_string_pretty(&value)?. In Node.js: import { stringify } from 'smol-toml'; const toml = stringify(JSON.parse(text)) — this is exactly the approach used by this tool. Remember that the top-level value must be an object in all of these.
Does the converter preserve key order?
Keys within a table are preserved in their original order, but TOML structure requires that all plain key-value pairs of a table come before any child table headers. So top-level scalars are emitted first, then tables and arrays of tables — the converter reorders only where the TOML grammar demands it. The data is identical; only the textual ordering of table sections shifts to produce valid TOML.
Is there a file size limit for JSON input?
There is no hard limit, but inputs over 200KB switch from live conversion to manual mode: a Convert button appears and conversion runs only when you click it, keeping the browser responsive. Typical configuration payloads convert in well under 50 milliseconds.

Related Tools

View all tools →