Boneyard Tools

JSON to TOML Converter

Paste a JSON object and this converter writes it out as TOML in real time. Plain values come first as key equals value lines, nested objects turn into [table] sections, and arrays of objects become [[array of tables]] blocks in document order. Everything runs in your browser, so config files with secrets never leave your device.

How to convert JSON to TOML

  1. Paste or type your JSON into the JSON input box, or click Load sample to start from an example.
  2. Make sure the top level is a JSON object, since a TOML document is a table and cannot start from a bare array or value.
  3. Watch the TOML output box update live as you edit, with any parse error shown in red above it.
  4. Click Copy to grab the TOML, or Download to save it as config.toml.

Examples

Object with a nested table

{"title":"My App","owner":{"name":"Ada","active":true}}
title = "My App"

[owner]
name = "Ada"
active = true

Array of objects becomes an array of tables

{"server":[{"host":"a"},{"host":"b"}]}
[[server]]
host = "a"

[[server]]
host = "b"

Numbers and an inline array stay on the top-level keys

{"name":"api","port":80,"ports":[8001,8002]}
name = "api"
port = 80
ports = [8001, 8002]

Frequently asked questions

Is my data uploaded anywhere?

No. The conversion runs entirely in your browser with JavaScript, so your JSON never touches a server. That makes it safe for config files that contain hostnames, tokens or other private values.

Why does the top level have to be an object?

A TOML document is itself a table, which maps to a JSON object. A bare array or scalar at the root has no valid TOML equivalent, so the converter reports an error asking you to wrap it in an object first.

How are nested objects converted?

Each nested object becomes a TOML table with a dotted header, such as [owner] or [server.db]. Plain key and value pairs for the current table are written first, then the table sections follow so the output parses cleanly.

What happens to arrays?

An array of primitive values is written inline, like ports = [8001, 8002]. An array where every item is an object becomes an array of tables using the [[name]] syntax, one block per item. A mixed array of objects and primitives is treated as an inline array instead.

What about null values?

TOML has no null type, so any JSON null is written as an empty string to keep the document valid. If you would rather drop those keys entirely, remove them from the JSON before converting.

Are special characters escaped?

Yes. Strings use TOML basic-string escaping for quotes, backslashes, tabs, newlines, form feeds and other control characters, and any code point below 0x20 becomes a \uXXXX escape. Keys that are not simple letters, digits, underscores or hyphens are quoted the same way.

How are non-finite numbers handled?

JSON itself cannot hold Infinity or NaN, but if such a value reaches the converter it is written using the TOML spellings inf, -inf and nan rather than being dropped.

Does it preserve the order of my keys?

Yes. Keys are emitted in the same order they appear in the object, with all inline values for a table printed before its nested tables so no key ends up stranded under the wrong header.

Can I convert TOML back to JSON here?

This tool only goes from JSON to TOML. For the reverse direction, or to tidy the JSON first, try a JSON formatter or a dedicated TOML to JSON converter.

Learn more

Related tools