elefcode

TOML ↔ JSON Converter

Convert TOML configuration to JSON and back. Tables, arrays of tables and inline tables all supported.

✓ Valid
{
  "title": "My Project",
  "version": "1.4.2",
  "tags": [
    "cli",
    "rust"
  ],
  "package": {
    "name": "widget",
    "edition": 2021
  },
  "dependencies": {
    "serde": {
      "version": "1.0",
      "features": [
        "derive"
      ]
    }
  },
  "bin": [
    {
      "name": "widget",
      "path": "src/main.rs"
    }
  ]
}

Advertisement

Guide

About the TOML ↔ JSON Converter

TOML is the configuration format behind Cargo.toml, pyproject.toml and netlify.toml. It is designed to be read by people, which makes it pleasant to edit and awkward to process with tools that expect JSON.

This converter goes both ways, so you can inspect a config as JSON or generate TOML from data you already have.

What TOML has that JSON does not

Comments, for a start — the single most common reason people reach for TOML over JSON. It also has first-class dates and times, integers in hex, octal and binary, underscores as digit separators (1_000_000), and multi-line strings. Converting to JSON flattens all of that: comments disappear entirely and dates become ISO strings, because JSON has nowhere to put them.

Tables, arrays of tables, and why both exist

A [table] header is a nested object. A [[array of tables]] header is an array of objects — repeat the header and you append another entry. That is how a Cargo.toml lists several binaries, and it is the part of the syntax people most often misread. Both convert cleanly in each direction here.

The round trip is not byte-identical

Converting TOML to JSON and back produces equivalent TOML, not identical TOML. Comments are gone, inline tables may be expanded into full table headers, and key order can shift. The data is the same — reparsing either version gives the same structure — but do not expect a clean diff against the original file.

Scalars are parsed, not guessed at

0xDEADBEEF becomes a number, 1_000_000 becomes 1000000, and 1979-05-27T07:32:00Z becomes a date. Literal strings in single quotes keep their backslashes, which is what makes them useful for Windows paths and regular expressions.

How to use it

  1. 1Paste your TOML, or switch direction and paste JSON.
  2. 2The conversion runs as you type; errors name the line.
  3. 3Use “Use output as input” to flip and convert back.
  4. 4Copy the result.

Frequently asked questions

What happens to comments?

They are lost. JSON has no comment syntax, so there is nowhere to put them. This is the main thing to be aware of before converting a config you intend to keep editing.

How are arrays of tables handled?

A [[products]] header becomes a JSON array of objects, and a JSON array of objects converts back into repeated [[header]] blocks.

Why did my dates become strings?

TOML has a real date type; JSON does not. Dates are emitted as ISO 8601 strings, which is the conventional representation and parses back correctly.

Is the round trip lossless?

The data is preserved, but formatting is not. Comments are dropped and inline tables may be rewritten as table headers — equivalent TOML, not identical TOML.

Is my config uploaded?

No. The parser runs entirely in your browser.

Related tools