Convert JSON to TOML

Drag and drop files here or click to select.
Max file size 100mb.
Uploading progress:

JSON vs TOML Format Comparison

Aspect JSON (Source Format) TOML (Target Format)
Format Overview
JSON
JavaScript Object Notation

A lightweight, text-based data interchange format derived from JavaScript object literal syntax. It is language-independent and used universally for APIs, configuration files, and data storage.

Data Format Universal Standard
TOML
Tom's Obvious Minimal Language

A minimal configuration file format designed to be easy to read due to its clear semantics. Created by Tom Preston-Werner (co-founder of GitHub), TOML maps unambiguously to a hash table and is the standard configuration format for Rust (Cargo.toml) and Python packaging (pyproject.toml).

Configuration Modern Standard
Technical Specifications
Standard: RFC 8259 / ECMA-404
Encoding: UTF-8 (mandatory)
Format: Text-based with strict syntax
Data Types: String, Number, Boolean, Array, Object, null
Extension: .json
Standard: TOML v1.0.0 Specification (toml.io)
Encoding: UTF-8 (mandatory)
Format: INI-inspired with typed values and tables
Data Types: String, Integer, Float, Boolean, Datetime, Array, Table
Extension: .toml
Syntax Examples

JSON uses curly braces for objects and square brackets for arrays:

{
  "package": {
    "name": "my-app",
    "version": "1.0.0",
    "authors": ["Alice", "Bob"]
  },
  "dependencies": {
    "serde": "1.0",
    "tokio": "1.28"
  }
}

TOML uses [table] headers and key = value pairs:

[package]
name = "my-app"
version = "1.0.0"
authors = ["Alice", "Bob"]

[dependencies]
serde = "1.0"
tokio = "1.28"
Content Support
  • Nested objects and arrays of arbitrary depth
  • Typed values: strings, numbers, booleans, null
  • Unicode text with escape sequences
  • Heterogeneous collections of mixed types
  • Key-value pair structures
  • Ordered arrays of elements
  • Complex hierarchical data trees
  • Tables (hash tables) with [section] headers
  • Strongly typed values with explicit type rules
  • Native datetime type (RFC 3339 format)
  • Inline tables for compact nested data
  • Arrays of tables using [[double brackets]]
  • Multi-line basic and literal strings
  • Comments with the # character on any line
Advantages
  • Human-readable and easy to write by hand
  • Native support in all modern programming languages
  • Supports complex nested and hierarchical structures
  • Self-describing with explicit key names
  • Compact compared to XML for equivalent data
  • Default format for REST APIs and web services
  • Unambiguous mapping to hash tables (no edge cases)
  • Native datetime type without custom parsing
  • Comments supported on any line
  • Clean INI-like syntax familiar to most developers
  • Standard config format for Rust and Python packaging
  • Strictly typed values prevent silent type coercion
Disadvantages
  • No native support for comments
  • No date/time or binary data types
  • Trailing commas cause parse errors
  • No schema enforcement built into the format
  • No null value support in TOML target
  • No null value type (cannot represent missing data)
  • Deeply nested structures become verbose with long table paths
  • Less widespread adoption than JSON or YAML
  • Arrays of tables syntax can be confusing for beginners
  • Not suitable for data interchange or API payloads
Common Uses
  • REST API request and response payloads
  • Application configuration files
  • NoSQL database storage (MongoDB, CouchDB)
  • Browser local storage and session data
  • Package manifests (package.json, composer.json)
  • Rust package manifests (Cargo.toml)
  • Python project configuration (pyproject.toml)
  • Go module configuration (go.mod companion files)
  • Hugo static site generator configuration
  • Deno runtime configuration (deno.toml)
Best For
  • Web API communication and microservices
  • Storing structured configuration data
  • Data serialization with nested objects
  • Cross-platform data interchange
  • Package manager and build tool configuration
  • Application settings with typed values and comments
  • Projects using Rust, Python (PEP 518), or Hugo
  • Configuration files where datetime support is needed
Version History
2001: Introduced by Douglas Crockford
2006: RFC 4627 published as informational
2013: ECMA-404 standard released
2017: RFC 8259 published as Internet Standard
2013: Created by Tom Preston-Werner (GitHub co-founder)
2014: Adopted by Rust's Cargo package manager
2017: PEP 518 standardized pyproject.toml for Python
2021: TOML v1.0.0 specification officially released
Software Support
Editors: VS Code, Sublime Text, Notepad++, Vim
Languages: JavaScript, Python, Java, C#, Go, PHP, Ruby
Databases: MongoDB, CouchDB, PostgreSQL, MySQL
Tools: jq, Postman, cURL, browser DevTools
Editors: VS Code (Even Better TOML), IntelliJ, Vim, Emacs
Languages: Rust (toml crate), Python (tomllib/tomli), Go (BurntSushi/toml), JS (smol-toml)
Build Tools: Cargo, pip/setuptools, Hugo, Deno
Tools: taplo (formatter/linter), toml-cli, dasel

Why Convert JSON to TOML?

Converting JSON to TOML is essential when working with modern language ecosystems that have adopted TOML as their standard configuration format. Rust's Cargo package manager uses Cargo.toml for project manifests, Python's PEP 518 mandates pyproject.toml for build system configuration, and Hugo uses config.toml for site settings. When your source data is in JSON and you need to create these configuration files, a JSON-to-TOML conversion bridges the gap.

TOML provides several advantages over JSON specifically for configuration files. It supports native datetime values (RFC 3339 format), eliminating the need to parse date strings manually. It includes inline comments for documenting configuration choices. And its strict typing prevents the silent type coercion problems that affect YAML, where values like "off", "no", and "1.0" can be unexpectedly interpreted as booleans or floats. TOML's unambiguous semantics ensure that what you write is exactly what you get.

The TOML format's INI-inspired syntax with [table] headers creates a visual structure that is immediately familiar to developers. Nested JSON objects become clearly delineated sections with descriptive headers, making TOML files easy to navigate even when they contain many configuration options. This clarity is particularly valuable for project configuration files that may be edited by many team members.

Key Benefits of Converting JSON to TOML:

  • Rust Ecosystem: Generate Cargo.toml manifests with proper package metadata and dependency specifications
  • Python Packaging: Create pyproject.toml files for modern Python build systems (PEP 518/PEP 621)
  • Native Datetime: Represent dates and times as first-class values without custom string parsing
  • Strict Typing: Avoid YAML's implicit type coercion with TOML's unambiguous value types
  • Comment Support: Document configuration decisions with inline and full-line comments
  • Clear Structure: Table headers create visually organized sections for related settings
  • Deterministic Parsing: Every TOML value maps to exactly one data type with no ambiguity

Practical Examples

Example 1: Rust Cargo Package Manifest

Converting a JSON package definition into a Cargo.toml file:

Input JSON file:

{
  "package": {
    "name": "my-cli-tool",
    "version": "0.3.1",
    "edition": "2021",
    "authors": ["Alice "]
  },
  "dependencies": {
    "serde": {"version": "1.0", "features": ["derive"]},
    "clap": "4.3"
  }
}

Output TOML file:

[package]
name = "my-cli-tool"
version = "0.3.1"
edition = "2021"
authors = ["Alice "]

[dependencies]
clap = "4.3"

[dependencies.serde]
version = "1.0"
features = ["derive"]

Example 2: Python pyproject.toml

Converting a JSON project definition into a pyproject.toml file:

Input JSON file:

{
  "build-system": {
    "requires": ["setuptools>=68.0", "wheel"],
    "build-backend": "setuptools.build_meta"
  },
  "project": {
    "name": "my-package",
    "version": "2.1.0",
    "requires-python": ">=3.8"
  }
}

Output TOML file:

[build-system]
requires = ["setuptools>=68.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "my-package"
version = "2.1.0"
requires-python = ">=3.8"

Example 3: Application Settings with Multiple Sections

Converting a JSON settings file into a structured TOML configuration:

Input JSON file:

{
  "title": "My Application",
  "database": {
    "server": "192.168.1.1",
    "ports": [8001, 8001, 8002],
    "enabled": true
  },
  "servers": {
    "alpha": {"ip": "10.0.0.1", "role": "frontend"},
    "beta": {"ip": "10.0.0.2", "role": "backend"}
  }
}

Output TOML file:

title = "My Application"

[database]
server = "192.168.1.1"
ports = [8001, 8001, 8002]
enabled = true

[servers.alpha]
ip = "10.0.0.1"
role = "frontend"

[servers.beta]
ip = "10.0.0.2"
role = "backend"

Frequently Asked Questions (FAQ)

Q: How are JSON null values handled in TOML?

A: TOML does not have a null type. JSON null values are either omitted from the TOML output or converted to empty strings, depending on the context. If null values are critical to your data, you may need to use a sentinel value or handle them in your application logic.

Q: Can TOML represent deeply nested JSON structures?

A: Yes, but the syntax becomes more verbose. Nested JSON objects are converted to dotted key paths or nested [table] headers. For example, {"a": {"b": {"c": 1}}} becomes [a.b] with c = 1. Very deeply nested structures are valid but may be less readable in TOML.

Q: How are JSON arrays of objects converted to TOML?

A: JSON arrays of objects are converted to TOML arrays of tables using the [[double.bracket]] syntax. Each object in the array becomes a separate [[table]] entry. This is the standard TOML pattern used in Cargo.toml for dependencies with complex configurations.

Q: Can I use the output directly as a Cargo.toml file?

A: Yes, provided your source JSON contains valid Cargo manifest structure with the required [package] section. The converted TOML follows the format expected by Cargo and can be used immediately in a Rust project.

Q: Does TOML support the same data types as JSON?

A: TOML supports all JSON types except null, and adds native datetime support (RFC 3339). TOML also distinguishes between integers and floats (JSON has only "number"), and strings in TOML are always quoted, preventing type ambiguity.

Q: What makes TOML better than JSON for configuration files?

A: TOML supports comments for documentation, has native datetime types, uses clean section headers instead of nested braces, and provides unambiguous type semantics. These features make TOML specifically designed for configuration, while JSON is designed for data interchange.

Q: Is there a file size limit for the conversion?

A: Our converter handles JSON files of any reasonable size. Complex nested structures with many levels of depth are fully supported. The conversion is processed server-side for optimal performance.