TOML ↔ JSON Converter

Convert TOML to JSON and JSON to TOML in either direction

Direction:

TOML Input

JSON Output

JSON will appear here

About

Convert between TOML and JSON in either direction. Pick a direction, paste your document, and convert. Useful for moving config between Rust/Python tooling (TOML) and the broader JSON ecosystem. Everything runs in your browser; nothing is uploaded.

    Examples

    TOML to JSON

    Input
    title = "Example Config"
    [database]
    host = "localhost"
    port = 5432
    tags = ["dev", "staging"]
    Output
    {
      "title": "Example Config",
      "database": {
        "host": "localhost",
        "port": 5432,
        "tags": ["dev", "staging"]
      }
    }

    TOML tables ([database]) become nested JSON objects; arrays are preserved as arrays.

    JSON to TOML

    Input
    {
      "title": "My Config",
      "servers": {
        "alpha": { "ip": "10.0.0.1", "dc": "us-east" },
        "beta": { "ip": "10.0.0.2", "dc": "us-west" }
      }
    }
    Output
    title = "My Config"
    
    [servers.alpha]
    ip = "10.0.0.1"
    dc = "us-east"
    
    [servers.beta]
    ip = "10.0.0.2"
    dc = "us-west"

    Nested JSON objects become TOML tables; top-level keys become TOML top-level entries.

    About this tool

    TOML and JSON are both structured data formats, but they serve different roles. TOML is designed for human-authored configuration files, while JSON is the lingua franca of APIs. Converting between the two is a common step when bridging a TOML config into a JSON-based tool, or when exporting structured TOML data into a web application.

    This converter handles both directions using the @iarna/toml library. TOML tables become nested JSON objects, arrays stay arrays, and inline tables are expanded to their full form. Converting JSON back to TOML requires the root to be an object — arrays at the root level have no TOML equivalent and are rejected.

    How to use

    1. Choose a direction

      Pick TOML → JSON or JSON → TOML. The editor and output panels update to reflect the chosen mode.

    2. Paste your input

      Drop a valid TOML or JSON document into the input panel. For TOML → JSON, first row = headers by default; for JSON → TOML, the root must be an object.

    3. Copy the result

      Click Copy to grab the converted output, or Download to save it as a file.

    Use cases

    Bridging TOML config into a JSON API

    Convert a Cargo.toml or pyproject.toml into JSON so a build script or CI pipeline can consume the data as structured JSON.

    Exporting TOML data to a web app

    Convert TOML config to JSON for consumption by a JavaScript or Node.js tool that only speaks JSON.

    Inspecting nested TOML as JSON

    Convert TOML to JSON to visualize the data model in a way that is familiar to developers who work with JSON daily.

    Common mistakes

    Mistake:Trying to convert a JSON array at the root level to TOML.

    Fix:TOML does not support arrays at the root level — only tables. Wrap the array in an object like { items: [...] } before converting.

    Mistake:Losing key order on round-trip.

    Fix:JSON objects have no guaranteed key order. TOML preserves the order of keys as written, but round-tripping through JSON may reorder them.

    Mistake:Expecting inline tables to expand in JSON→TOML.

    Fix:Inline tables in JSON stay inline in TOML (a = { b = 1 }); only regular nested objects expand to TOML table form.

    Frequently asked questions

    References & standards