JSON Input JSON
โš ๏ธ Invalid JSON โ€” please check your input.
TOML Output TOML
Advertisement
What does a JSON to TOML converter do? A JSON to TOML converter rewrites a JSON object in TOML, the key = value config format used by Cargo, Hugo and Python packaging. This one writes scalars first, nested objects as [tables], arrays of objects as [[array tables]], skips null values, and needs a JSON object at the top level. It runs in your browser.

What does a JSON to TOML converter do?

TOML is a configuration format built for people to edit. Where JSON nests braces inside braces, TOML flattens the shape into section headers like [database] and plain key = "value" lines. Tools such as Cargo, Hugo and many Python build systems read it, so a JSON sample often needs converting.

This JSON to TOML converter reads your JSON with the browser's parser and writes TOML in a fixed order. Plain values come first. Nested objects follow as tables, with dotted headers such as [profile.release]. An array that contains only objects becomes repeated [[servers]] blocks. Two checkboxes change the style: Use inline tables for simple objects and Add type comments.

There are real limits. TOML cannot store null, so keys with null values are left out. A TOML file must be a table at the top, so a JSON array or bare value gets a short comment asking you to wrap it. The tool does not check the result against the TOML specification. For the opposite direction, use the TOML to JSON converter.

How to convert JSON to TOML here

  1. Paste a JSON object into JSON Input, or click Sample to load a Cargo-style package.
  2. Tick Use inline tables for simple objects if you want point = {x = 1, y = 2} instead of a separate [point] section.
  3. Tick Add type comments to put a comment such as # string or # integer above each plain value.
  4. Click Convert. Invalid JSON shows a red warning and no output.
  5. Read the output: look for dropped nulls and any quoted keys.
  6. Use Copy, or Download .toml to save output.toml.

How this tool writes TOML

Tables from nested objects

A nested object becomes a header like [a.b], built from its path. Empty objects still produce a header with no keys.

Arrays of tables

When every item in an array is an object, each one is written as its own [[name]] block, with sub-tables nested under it.

Inline tables option

Objects with only simple values can be written on one line in braces. Objects holding further objects still become tables.

Type comments

Adds a line such as # integer, # float, # string, # boolean or # array before each plain key.

Quoted keys

Keys that contain anything beyond letters, digits, underscore and hyphen are put in double quotes, so a key with a space stays valid.

Null and type rules

Null values are skipped, and null items inside plain arrays are removed. Mixed-type arrays are written as they are.

Where JSON to TOML conversion is useful

  • Starting a Cargo.toml or pyproject.toml. You have settings in JSON and want the same data as TOML sections. Convert, then reorder the tables to match your tool's layout.
  • Moving a Hugo or static site config. Many sites keep a JSON config. Turning it into TOML gives you comments and shorter nesting.
  • Seeing how arrays of objects look in TOML. The [[array]] syntax is the part people forget. Converting a list of servers shows it at once.
  • Documenting config in a README. Type comments help readers see each field's type when you paste a sample into docs.

Tips for clean TOML output

  • Wrap arrays or single values in an object first, for example {"items": [...]}, since the document root must be a table.
  • Look for missing keys. Anything that was null is gone, so replace it with a real default or an empty string if you need the key.
  • Use inline tables for small things like coordinates, and leave them off for sections you want to comment by hand.
  • Check numbers. JSON 2.0 is parsed as the integer 2, so the TOML shows 2, not 2.0. Strings that look like numbers stay quoted.
  • Run the TOML through your own tool afterwards. See also the JSON formatter if the input was hard to read.

Is it safe? Privacy and limits

Everything happens in your browser. The JSON is parsed with JSON.parse, and the TOML string is built by local JavaScript, so nothing is uploaded and no account is needed. The converter does not validate the TOML against the 1.0 specification or the schema of the tool that will read it. Review the file, especially after dropped nulls, before putting it into a project.

JSON to TOML converter FAQ

TOML has no null type, so there is nothing valid to write. The converter skips any key whose value is null, and removes null entries inside plain arrays. If your application needs the key to exist, give it a stand-in value before converting, such as an empty string, zero or false, or handle the missing key in code. Do not rely on the output to tell you which fields were null in the original.

Not directly. A TOML document is always a table of keys, so the root must be a JSON object. If you paste an array or a bare value, the output box shows a short comment asking you to wrap it. Put it under a key, for example {"servers": [...]}, and convert again. The converter will then write the objects as [[servers]] blocks. If you are not sure the JSON is valid, run it through the JSON formatter first, which will point out syntax errors before you convert.

Turn them on when objects are small and flat, such as {x = 1, y = 2}, and you want fewer section headers. The tool only uses the inline form for objects whose values are not themselves objects. Objects with nested objects still become [tables]. Leave the option off when you plan to add comments to each key, since inline tables must stay on one line and cannot hold comments inside them.

If every item in an array is an object, each one is written as a [[name]] block. Any nested object inside an item becomes a sub-table with a dotted header, like [servers.limits]. Arrays that mix objects and other values are written as a single inline array, with objects shown as inline tables. This matters for tools such as Cargo, which expects [[bin]] sections for several binaries. Cargo-style manifests are a typical case.

Each plain key gets a comment line above it naming the JSON type: string, integer, float, boolean or array. For example, a port field shows # integer then port = 8080. Comments are only added for plain values, not for tables. They are useful when you want to document a sample or teach TOML, but remove them for a production file if your team does not want extra lines. They are plain comments, so TOML parsers ignore them.

No. JSON has no date type, so a date is written as an ordinary quoted string. Strings with line breaks are written on one line with \n escapes, not as triple-quoted blocks, and carriage returns are removed. JSON cannot hold Infinity or NaN, so they do not appear. If you need native TOML datetimes, edit the output by hand and remove the quotes. Date-time values are the most common reason to edit by hand.

It follows common TOML rules, with quoted keys, escaped strings and correct table headers, but there is no validation step. Odd inputs, such as keys that clash after quoting or very deep arrays of arrays, may need a manual fix, and the tool will not warn you when that happens. Always load the result with the parser your project uses, such as Cargo or a TOML library, before relying on it.

No. Conversion is done by JavaScript in the page, with no network request involved. There is no signup and no saved history, and the download button creates output.toml on your own device. If you work with sensitive config, avoid pasting real passwords or tokens into any online tool, and use fake values for samples. Related converters on this site, like JSON to XML, work the same way, locally in the tab.

Advertisement