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.
Options · 2 spaces
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
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
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
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.
[1, 2, 3]
{ "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.
{ "name": "a", "nickname": null } { "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.
{ "ports": [8001, null, 8003] } { "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.
{ 'name': 'a', 'active': true, } { "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.
{ "ratio": 1.0 } → ratio = 1 { "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.
{ "server": { "a": 1 }, "server": [1] } { "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?
What is TOML and why convert JSON to it?
Why must the top level of my JSON be an object?
What happens to null values when converting JSON to TOML?
How are nested objects and arrays converted to TOML?
What happens to floating-point numbers like 1.0?
Is my JSON data sent to any server?
Can I convert TOML back to JSON?
How do I convert JSON to TOML on the command line?
How do I convert JSON to TOML in Python, Rust, or Node.js?
Does the converter preserve key order?
Is there a file size limit for JSON input?
Related Tools
View all tools →Base64 Decoder & Encoder
Encoding & Formatting
Decode and encode Base64 online for free. Real-time conversion with full UTF-8 and emoji support. 100% private — runs in your browser. No signup needed.
Base64 to Image Converter
Encoding & Formatting
Decode a Base64 string or data URI back into an image in your browser. Preview, read dimensions & MIME, then download as PNG, JPG, GIF, SVG. No upload.
CSV to JSON Converter
Encoding & Formatting
Convert CSV to JSON in your browser. RFC 4180, type inference, header row, big-int safe. 100% private, no upload.
.env to JSON Converter
Encoding & Formatting
Paste a .env file, get JSON instantly. Your database passwords, API keys and tokens never leave your browser — 100% private, no upload, free dotenv parser.
Free HTML Entity Decoder — Unescape HTML
Encoding & Formatting
Decode HTML entities and unescape HTML online — free, no signup, 100% in your browser. Converts named, decimal & hex references back to characters; never uploaded.
Free HTML Entity Encoder — Escape HTML
Encoding & Formatting
Encode HTML entities and escape special characters (< > & " ') online — free, no signup, 100% in your browser. Named, decimal, or hex output; never uploaded.