CruxDevCruxDev Tools Prompts
dev Utility • Zero-Server Privacy • 100% Client-Side

JSON ↔ TOML Converter

Bi-directional conversion between JSON and TOML formats with proper type mapping for dates, arrays, and nested tables.

Overview

Convert a JSON configuration object into TOML text. Top-level scalars become key-value pairs and nested objects become TOML tables, with a live preview, an inline error comment for invalid JSON, and one-click copy. The conversion runs entirely in your browser.

How It Works

A server-configuration sample loads by default so the mapping from JSON nesting to TOML tables is visible immediately. Edit the JSON and the TOML output updates as you type; both panels include download buttons for .json and .toml files. Invalid JSON is reported as a TOML comment at the top of the output that includes the parser's error message. Click either editor to copy its contents.

Step-by-Step Usage Guide

  1. Paste the JSON object into the JSON input editor.
  2. Watch the TOML output update live, with table sections ordered after the scalar keys.
  3. Fix any error comment shown when the JSON does not parse.
  4. Copy the TOML or download it as config.toml.

Technical Specifications & Standards

The serializer is a small local implementation, not a general TOML library, and its structural assumptions are visible in the output. Strings are emitted as TOML basic strings using JSON escaping, booleans and numbers are written natively, and arrays become inline arrays. Nesting is handled to exactly two levels: a top-level object becomes a [table] section, but an object nested inside that table has no table representation in the generator, so it is serialized as a JSON string in the value position. The same happens for arrays of objects, where each element becomes a quoted JSON string rather than an array of tables. TOML 1.0, published in January 2021, has no null value, so JSON null is written as the quoted string "null". Keys are not quoted, so a key containing a dot would be read as a dotted key by real TOML parsers, and a key with a space would be invalid. For flat or two-level configurations the output is exact; for deeper structures, restructure the JSON before converting.

Targeted Use Cases

  • Migrating a settings.json file to a TOML-based tool such as a Rust or Python project configuration.
  • Producing starter TOML from an existing JSON file when adopting a new tool.
  • Comparing JSON and TOML side by side when choosing a configuration format.
  • Generating example TOML snippets for documentation from JSON examples.

Notes & Gotchas

  • Keep the source JSON to two levels of nesting so every value maps to real TOML syntax.
  • Avoid keys with dots or spaces; rename them before converting.
  • Replace null values with explicit defaults, since TOML cannot express null.
  • Validate the result in the consuming tool afterwards, especially if arrays contained objects.

Frequently Asked Questions

Why did my nested object turn into a quoted JSON string?

The generator maps one level of tables. Anything deeper is written as a JSON string in the value position, which is valid TOML but not a nested table. Flatten the JSON or move that section to its own top-level object before converting.

How are JSON nulls handled?

TOML has no null. The serializer writes the string "null", which reads back as text, not as a missing value. Replace nulls with empty strings, zeros, or omit the key entirely.

Is the output TOML 1.0 compliant?

For scalars, arrays, and one level of tables, yes. The quoted-string fallback for deeper nesting is also syntactically valid TOML, but it does not preserve the original structure, so treat it as a placeholder rather than a faithful conversion.

Does this tool work offline?

Yes. The parser and serializer are plain JavaScript bundled with the page. Nothing is uploaded, and no network request is needed once the site has loaded.