json to toml converter

typetools

instant, client-side type converter • 0ms network latency

root:
inputjson
paste or drop file
307 chars
outputtoml
*.toml
userId = "usr_98a7c2f1"
username = "alex_dev"
email = "alex@example.com"
isActive = true
score = 98.4
roles = ["admin","editor"]
tags = ["prod",42,null]

[metadata]
lastLogin = "2026-10-15T12:00:00Z"
ipAddress = "192.168.1.1"
0.15ms•in-browser
documentation, edge cases & specifications below

step-by-step integration guide

technical specification differences & end-to-end conversion workflow

Restructuring Deep JSON Trees into Idiomatic TOML Table Sections

Converting JSON into TOML v1.0 requires a structural reordering of keys at every level of the syntax tree. In a JSON object, scalar primitives (strings, numbers, booleans) and nested child objects can be interleaved in any arbitrary order. In TOML, however, once a table header like [database] is declared, every subsequent key-value line belongs to that [database] table until the next [header] appears. If a naive converter emits a child table header before emitting all sibling scalar keys of the parent object, those trailing scalar keys will be accidentally nested inside the child table, corrupting the configuration structure. Furthermore, TOML v1.0 has no native null keyword.

Two-Phase Topological Sorting for Primitives, Tables, and Arrays of Tables

Our JSON-to-TOML serializer resolves these structural constraints by performing a topological sort at every object node in the AST. For each object level, the emitter partitions keys into three distinct groups: (1) primitive scalars and primitive arrays, (2) nested child objects, and (3) arrays of objects. It always emits all primitive key-value pairs first at the top of the current scope, followed by nested [parent.child] table sections, and finally [[parent.list]] Array of Tables blocks. Because TOML v1.0 explicitly omits a null primitive, any JSON property with a null value is safely commented out or omitted so the resulting configuration passes strict taplo, Cargo, and Python tomllib validation.

frequently asked questions

common developer questions answered

q:How does the converter handle JSON 'null' values since TOML v1.0 has no null type?

Unlike JSON and YAML, the TOML v1.0 specification does not have a null literal. In TOML, an unset value is represented by omitting or commenting out the key (# key = null), which our serializer handles automatically.

q:Why does the converter reorder primitive fields above nested objects in the TOML output?

In TOML syntax, all keys written after a [table] header belong to that table. Emitting scalar primitives before any [subtable] headers prevents top-level keys from being swallowed by child tables.

q:Can a JSON array stay at the root of a TOML document?

A valid TOML document must always be a key-value table at its root. If you paste a top-level JSON array, the converter automatically wraps it in a root [[items]] Array of Tables so it remains valid TOML.

topic cluster

related type & ast converters

3 interconnected tools