Data Converters

TOML to JSON Converter: Parse Cargo.toml and Config Files

Convert TOML configuration files to JSON online. Supports all TOML v1.0 features including tables, arrays of tables, inline tables, and datetime values.

Published January 15, 2025Updated June 1, 20254 min read

Try the free online tool

Runs entirely in your browser — no signup, no uploads.

Open Tool

TOML (Tom's Obvious, Minimal Language) is a configuration file format designed to be easy to read and write by humans while mapping unambiguously to a hash table. It is the native configuration format for Rust projects (Cargo.toml), a popular choice in Go projects, and used by tools like the Python Poetry package manager and the Hugo static site generator. TOML's explicit, INI-inspired syntax makes configuration intent clear without the indentation sensitivity of YAML or the verbosity of XML.

While TOML is excellent as a human-authored format, many configuration management systems, APIs, and tooling pipelines expect JSON. Converting TOML to JSON is a common step when integrating Rust or Go configuration with JavaScript tooling, when passing configuration to JSON-only APIs, or when inspecting the parsed structure of a complex TOML file that uses tables and arrays of tables.

This converter fully supports TOML v1.0, including all table types (regular tables, inline tables, and arrays of tables), all native scalar types (strings, integers, floats, booleans, and datetimes), and multiline strings. The output is well-structured JSON that accurately represents the full TOML data model.

What Is TOML and When Is It Used?

TOML was created by Tom Preston-Werner (co-founder of GitHub) as a minimal configuration format with an unambiguous specification. It takes inspiration from INI files but adds a richer type system and a clear hierarchical structure through sections called tables. A TOML file is organized into key-value pairs, regular tables ([table-name]), and arrays of tables ([[array-table-name]]), which map directly to nested JSON objects and arrays.

TOML's key advantages over YAML include: no indentation sensitivity (structure is defined by section headers, not spaces), explicit native types for integers, floats, booleans, and RFC 3339 datetime values, and a stricter specification that leaves less room for parser disagreement. These properties make TOML particularly well-suited for developer tooling configuration, where correctness and predictability are critical.

Common TOML files include Cargo.toml (Rust packages), pyproject.toml (Python projects), config.toml (Hugo), and netlify.toml (Netlify deployment configuration). If you work with any of these ecosystems, you will encounter TOML regularly.

How to Use This Tool

Follow these steps to convert TOML to JSON:

  1. 1

    Paste your TOML file

    Copy the contents of your TOML configuration file into the input panel. Cargo.toml, pyproject.toml, config.toml, and any other TOML v1.0 files are supported.

  2. 2

    Click Convert

    Press the Convert button. The parser reads the TOML, resolves the table structure and array-of-tables constructs, and converts the result to an equivalent JSON object. Syntax errors are shown with line and column information.

  3. 3

    Review the structure

    Examine the JSON output to verify that tables, inline tables, and arrays of tables are mapped correctly. Arrays of tables in TOML become JSON arrays of objects.

  4. 4

    Set output format

    Choose between pretty-printed JSON with indentation for readability, or minified JSON for use in scripts, environment variables, or API calls.

  5. 5

    Copy or download

    Click Copy to place the JSON on your clipboard, or Download to save a .json file. The JSON is ready for immediate use in your tooling pipeline.

Common Use Cases

TOML to JSON conversion is useful in these development scenarios:

  • Extracting dependency information from Cargo.toml for use in JavaScript build tools or dependency analysis scripts
  • Converting pyproject.toml configuration to JSON for ingestion by project management or vulnerability scanning tools
  • Parsing Hugo config.toml or config.toml from Go projects for inspection with jq or JavaScript tooling
  • Transforming netlify.toml and similar deployment configuration into JSON for CI/CD pipeline processing
  • Debugging complex TOML files with arrays of tables by viewing the resolved JSON structure to verify nesting is correct

Tips and Best Practices

Follow these guidelines for effective TOML to JSON conversion:

  • TOML datetime values (RFC 3339 format, e.g., 1979-05-27T07:32:00Z) are converted to ISO 8601 strings in JSON. Verify that your downstream system handles this string format if you are using TOML's native datetime type.
  • Arrays of tables ([[section]]) are one of TOML's most powerful features but can be confusing. In the JSON output, they become arrays of objects. If you are constructing TOML by hand, use this converter to verify that your table structure produces the expected JSON nesting.
  • TOML distinguishes between integers and floats (3 versus 3.0). JSON does not differentiate, but the values are preserved correctly in the output. Note that TOML also supports special float values like inf and nan, which are not valid JSON and will be converted to strings.
  • Comments in TOML files are discarded during conversion because JSON has no comment syntax. If your TOML file uses comments heavily for documentation, consider keeping the TOML as the source of truth and only converting to JSON when needed by a downstream tool.
  • For programmatic TOML-to-JSON conversion in scripts, use the toml-to-json or tomli Python packages, the toml Go package, or the TOML crate in Rust for reliable, automatable conversion.

Frequently Asked Questions

What is the difference between a TOML table and an array of tables?

A regular table ([section]) creates a single JSON object. An array of tables ([[section]]) allows multiple instances of the same section name, which are collected into a JSON array of objects. This is TOML's way of representing lists of structured records, such as a list of dependencies or multiple server configurations.

Are TOML inline tables converted correctly?

Yes. Inline tables (e.g., point = {x = 1, y = 2}) are converted to JSON objects ({"x": 1, "y": 2}). They behave identically to regular tables in the JSON output, differing only in how they are authored in the TOML source.

How does the converter handle TOML's native datetime type?

TOML has four datetime types: offset datetime, local datetime, local date, and local time. All are serialized as strings in JSON since JSON has no native datetime type. Offset datetimes use ISO 8601 format with the UTC offset preserved.

Can I convert a Cargo.toml with workspace dependencies?

Yes. Cargo.toml with [workspace], [workspace.dependencies], and path/version-based dependencies are all valid TOML and are converted correctly to JSON. The resulting JSON mirrors the TOML structure exactly, which is useful for tooling that needs to inspect Cargo workspace configuration.

Does TOML support comments, and are they preserved?

TOML supports single-line comments using the # character. Comments are not part of the data model and are discarded during parsing, so they do not appear in the JSON output. If you need to preserve configuration documentation, consider using a separate documentation file or a TOML tool that supports comment-annotated ASTs.

What is the relationship between TOML and JSON in terms of data types?

TOML has a richer type system than JSON. Both support strings, booleans, integers, floats, arrays, and objects (called tables in TOML). TOML additionally has native datetime types and distinguishes integers from floats, while JSON treats all numbers uniformly. TOML multiline strings are serialized as regular JSON strings.

tomljsonconversionrustcargoconfigurationgolang

Ready to use this tool?

Free, instant, no account required. Runs entirely in your browser.

Open Tool

More Data Converters Guides