TOML to JSON and YAML Converter

Convert TOML to JSON or YAML and back with TOML 1.0 validation, line-numbered errors and warnings for nulls, dates and big integers. For Cargo and pyproject files.

The interactive tool loads here when JavaScript runs.

About this tool

What is the TOML Converter?

Paste a TOML file and this converter shows it as JSON or YAML while you type, or go the other way and turn JSON or YAML into TOML. Parsing and writing use smol-toml, a parser that follows the TOML 1.0.0 specification, and the YAML side uses the yaml package with the YAML 1.2 core schema. Choose TOML in both boxes to validate a file and print it back in normalised form.

When the input is invalid you get the parser's message with the line and column, for example a key defined twice or a table redefined later in the file. When the conversion is valid but a value cannot travel to the target format, the tool says so instead of changing it quietly: nulls removed on the way into TOML, integers above 2^53 that JavaScript-based JSON readers will round, and inf or nan, which JSON cannot represent.

It is handy for reading Cargo.toml, pyproject.toml, netlify.toml or Hugo config as JSON, for generating TOML from a script's JSON output, and for moving configuration between tools that prefer different formats. Nothing is uploaded.

  • TOML 1.0.0 parsing and writing with smol-toml
  • TOML, JSON and YAML in any direction
  • Errors with line and column numbers
  • Warnings for nulls, large integers, inf and nan
  • Optional conversion of date strings to native TOML dates
  • Arrays of tables written as [[name]] sections
  • Runs locally in the browser
Read the guide: TOML Explained: Syntax, Types and Converting to JSON and YAML

How to use the TOML Converter

  1. Choose the input format in From and the output format in To. The sample changes to match the input format.
  2. Paste your document. The output updates as you type.
  3. If there is an error, read the line and column in the red box and fix the input.
  4. Check the yellow notes for values that changed, such as removed nulls or large integers.
  5. Copy or download the result, or press the swap button to continue editing in the other format.

Worked examples

A Cargo manifest to JSON

Input

[package]
name = "demo"
version = "0.1.0"

[dependencies]
serde = { version = "1.0", features = ["derive"] }

Output

{"package":{"name":"demo","version":"0.1.0"},"dependencies":{"serde":{"version":"1.0","features":["derive"]}}}

Each [table] becomes an object and the inline table becomes a nested object. The real output is indented with 2 or 4 spaces.

A null on the way into TOML

Input

{"name":"x","homepage":null}

Output

name = "x"

homepage is removed and a note lists the path, because TOML has no null. Omitting the key is the usual TOML way to say "not set".

A duplicate key

Input

title = "a"
title = "b"

Output

Invalid TOML at line 2, column 1: trying to redefine an already defined table or value

TOML forbids defining a key twice, unlike JSON parsers that silently keep the last value. The error points straight at the second definition.

Background and insight

TOML (Tom's Obvious, Minimal Language) was created by Tom Preston-Werner, a GitHub co-founder, in 2013, and reached version 1.0.0 in January 2021. It is designed to map unambiguously to a hash table, with a small set of types: strings, 64-bit integers, IEEE 754 floats, booleans, arrays, tables, and four date and time types (offset date-time, local date-time, local date and local time). Rust's Cargo uses it for every package manifest, Python standardised pyproject.toml in PEP 518 and PEP 621, and Python 3.11 added tomllib to the standard library to read it.

Converting is mostly direct, with three edges. TOML has no null, so a JSON key whose value is null must be dropped or replaced; the converter drops it and lists the path. TOML dates are a real type, but JSON has none, so they become RFC 3339 strings such as "1979-05-27T07:32:00-08:00"; on the way back, tick the date option to turn such strings into native TOML dates again. And TOML integers are 64-bit, while JavaScript numbers are exact only up to 2^53 (9,007,199,254,740,992), so larger values are kept exact in the JSON text but flagged.

Tables come out the way TOML style guides recommend: simple keys first, then [section] headers for nested tables and [[double brackets]] for arrays of tables, which is how Cargo writes [[bin]] targets. Inline tables in the input, such as serde = { version = "1.0", features = ["derive"] }, become ordinary nested objects in JSON and YAML.

Common use cases

  • Rust and Python projects

    Read Cargo.toml or pyproject.toml as JSON for a script, or check a hand-edited manifest before committing.

  • Static site config

    Move Hugo or Zola settings between config.toml, config.yaml and JSON.

  • Generating config from code

    Turn the JSON your script produces into TOML for tools that only read TOML.

  • Validating CI and deploy files

    Catch syntax mistakes in netlify.toml, fly.toml or similar files before a failed deploy tells you.

Tips and limitations

  • JSON numbers such as 1.0 parse as 1 and are written to TOML as the integer 1. If a program expects a float there, edit it to 1.0 after converting.
  • Comments are not part of the data, so they are lost when converting to JSON or YAML and back. Keep the original TOML file as the source of truth.
  • Key order is preserved by default. Tick Sort keys for stable, diff-friendly output.
  • YAML anchors and aliases are expanded into copies on the way to TOML, because TOML has no references.
  • Only the first document of a multi-document YAML file (separated by ---) is converted; the tool tells you when there are more.
  • Local times such as 07:32:00 have no date or time zone. In JSON they become plain strings like "07:32:00".

Frequently asked questions

Does TOML support null?

No. TOML 1.0 has no null value. The usual approach is to leave the key out, or use an empty string or a sentinel your program understands. The converter removes null keys and tells you which ones.

How are TOML dates represented in JSON?

As strings in RFC 3339 form, for example "1979-05-27T07:32:00-08:00" for an offset date-time, "1979-05-27" for a local date and "07:32:00" for a local time.

Can I convert JSON with an array at the top level to TOML?

Not directly, because a TOML document is always a table of keys. Wrap the array in an object, for example {"items": [...]}, and it becomes an array of tables written as [[items]].

Are comments kept when I convert TOML to JSON?

No. JSON has no comments and YAML output is generated from the data, so comments are dropped. Converting TOML to TOML also drops them because the file is rebuilt from its values.

What happens to very large integers?

TOML allows 64-bit integers. Values beyond 2^53 are kept exactly in the JSON text, but many JSON parsers, including JavaScript's, will round them, so the tool warns you.

Is this a TOML validator too?

Yes. Choose TOML as both input and output: a valid file is printed back in normalised form, and an invalid one shows the error with its line and column.

Is there an in-depth guide to the TOML Converter?

Yes. “TOML Explained: Syntax, Types and Converting to JSON and YAML” covers the background, how it works, common pitfalls and worked examples. Read the full guide.

People also search for

  • convert cargo.toml to json
  • pyproject.toml to json online
  • json to toml converter with arrays of tables
  • toml validator with line numbers
  • yaml to toml for hugo config
  • does toml support null values
  • toml array of tables to json
  • toml datetime to json string