TOML Editor & Validator
Validate, format, minify, and convert TOML with a live tree view and JSON conversion
Parsing…
Tip: In the Tree View, hover any node and click its path badge to copy the full dot-notation path.
Your Cargo.toml has a syntax error somewhere in 80 lines — Rust’s error message says “expected a table key” but doesn’t tell you which line. You need a TOML editor that shows real-time validation with line numbers, so you can find the missing bracket or unescaped string immediately.
Why This Editor (Not the TOML-JSON Converter)
PureDevTools has a TOML-JSON Converter for format conversion. This tool is a full-featured TOML editor — syntax validation with real-time error messages and line numbers, TOML↔JSON conversion, format/minify, and an interactive tree view. Use the converter for quick format switching; use this editor for writing and debugging TOML files.
TOML Editor & Validator — Full-Featured Browser Tool
TOML (Tom’s Obvious, Minimal Language) has become the configuration standard for Rust projects (Cargo.toml), Python packaging (pyproject.toml), Hugo sites, and many modern developer tools. Despite its design goal of being obvious and minimal, TOML syntax errors — duplicate keys, unclosed strings, wrong table nesting — can be difficult to track down without a dedicated validator.
This free online TOML editor provides real-time syntax validation with precise line and column error reporting, automatic formatting, minification, TOML ↔ JSON conversion, and an interactive tree view. All processing runs entirely in your browser with no data sent to any server.
Core Features
Real-Time Syntax Validation
As you type, the editor validates your TOML against the TOML 1.0 specification. Errors are reported with exact line and column numbers where available. Common errors detected include:
- Duplicate keys — TOML prohibits defining the same key twice in the same table
- Unclosed strings — basic strings (
"...") and literal strings ('...') must be properly terminated - Invalid values — malformed integers, floats, or datetime literals
- Malformed table headers —
[section]and[[array-of-tables]]must follow key syntax rules - Inline table violations — inline tables must not span multiple lines
Format / Prettify
Click Format to normalize your TOML into clean, canonical output. The formatter round-trips your TOML through the internal parser — this removes comments, normalizes whitespace, consistently orders keys within sections, and separates tables with blank lines. Enable Sort Keys to output all keys in alphabetical order recursively.
Minify
Click Minify to strip all comment lines and blank lines from your TOML while preserving its key-value structure. Unlike Format, Minify keeps the original TOML structure intact — only # comment lines and empty lines are removed. This is useful for compact configuration deployment where comments are not needed.
TOML → JSON
Convert any valid TOML document to a formatted JSON object. Arrays of tables ([[...]]) become JSON arrays, standard tables become nested objects, and all TOML scalar types are converted to their JSON equivalents. Enable Sort Keys to produce alphabetically ordered JSON.
JSON → TOML
Convert a JSON object to TOML format. The converter handles nested objects as TOML tables, arrays of objects as TOML array-of-tables ([[...]]), and all JSON value types. Note: JSON null values are skipped since TOML has no null type.
Interactive Tree View
The tree view renders your parsed TOML document as an expandable, collapsible node hierarchy. Each node displays:
- The key name or array index
- A type badge:
string,number,boolean,null,array, orobject - The scalar value for leaf nodes (truncated if long)
- A copy path button — hover any node and click its path badge to copy the full dot-notation path to your clipboard
The tree view is particularly useful for exploring large, deeply nested TOML files like Cargo.lock or complex pyproject.toml configurations.
TOML Syntax Reference
Strings
TOML supports four string types:
# Basic string (supports escape sequences)
name = "Alice"
greeting = "Hello\nWorld"
# Multi-line basic string (preserves newlines after opening """)
description = """
This is a
multi-line string.
"""
# Literal string (no escape processing)
path = 'C:\Users\alice\Documents'
# Multi-line literal string
regex = '''
^[a-z]+$
'''
Integers
# Decimal
port = 8080
negative = -42
# Hexadecimal (prefix 0x)
hex_color = 0xDEADBEEF
# Octal (prefix 0o)
permissions = 0o755
# Binary (prefix 0b)
flags = 0b11010110
# Underscores for readability
one_million = 1_000_000
Floats
pi = 3.14159
avogadro = 6.626e-34
negative = -0.5
# Special float values
positive_inf = inf
negative_inf = -inf
not_a_number = nan
Booleans
enabled = true
disabled = false
Dates and Times
# Offset Date-Time (RFC 3339)
created_at = 1979-05-27T07:32:00Z
updated_at = 2024-01-15T12:00:00+05:30
# Local Date-Time
meeting = 2024-03-20T14:30:00
# Local Date
birthday = 1990-06-15
# Local Time
alarm = 07:30:00
Arrays
# Inline array
colors = ["red", "green", "blue"]
primes = [2, 3, 5, 7, 11]
# Mixed types allowed in arrays
mixed = [1, "two", 3.0, true]
# Multi-line array
hosts = [
"alpha.example.com",
"beta.example.com",
"gamma.example.com",
]
Tables (Objects)
# Standard table header
[server]
host = "localhost"
port = 8080
# Dotted key (equivalent to nested table)
database.host = "db.example.com"
database.port = 5432
# Inline table (must fit on one line)
coordinates = { x = 10.5, y = 20.3 }
Array of Tables
# Each [[products]] adds a new item to the products array
[[products]]
name = "Widget"
price = 9.99
tags = ["hardware", "gadget"]
[[products]]
name = "Gizmo"
price = 24.99
tags = ["software"]
Common TOML Errors and Fixes
Duplicate Key
Error: Duplicate key: "host"
Cause: The same key is defined twice at the same table level.
Fix: Remove the duplicate. In TOML, each key must appear exactly once per table.
# Wrong
[server]
host = "localhost"
host = "127.0.0.1" # Error: duplicate
# Correct
[server]
host = "localhost"
Key Conflict Between Table and Key
Error: "database" already has a non-table value
Cause: A key is defined as a scalar value and then used as a table header.
Fix: Ensure a key is either a scalar or a table, not both.
# Wrong
database = "sqlite"
[database] # Error: database is already a string
host = "localhost"
# Correct — use a different key
db_engine = "sqlite"
[database]
host = "localhost"
Unclosed String
Error: Unclosed basic string
Cause: A double-quoted string is not terminated on the same line.
Fix: Add the closing ". If the value spans multiple lines, use """...""" (multi-line basic string).
# Wrong
title = "My Application
# Correct
title = "My Application"
# Multi-line value
description = """
My Application
that spans lines.
"""
Invalid Inline Table Newline
Error: Expected value at position N
Cause: An inline table {...} spans multiple lines, which TOML 1.0 forbids.
Fix: Either keep the inline table on one line, or convert to a standard table section.
# Wrong
server = {
host = "localhost",
port = 8080
}
# Correct — inline table on one line
server = { host = "localhost", port = 8080 }
# Or use a standard table
[server]
host = "localhost"
port = 8080
TOML vs JSON vs YAML
| Feature | TOML | JSON | YAML |
|---|---|---|---|
| Comments | Yes (#) | No | Yes (#) |
| Multi-line strings | Yes (basic and literal) | No | Yes (block scalars) |
| Trailing commas | N/A | No | N/A |
| Datetime type | Yes (native) | No (string) | Yes (via tag) |
| Integer bases | Yes (hex, octal, binary) | No | No |
| Anchors/aliases | No | No | Yes |
| Readability | High | Medium | High |
| Parsing complexity | Medium | Low | High |
When to choose TOML: Rust projects (Cargo), Python packaging (pip, Poetry), Hugo, configuration files where comments and readability matter. TOML is unambiguous by design — there is exactly one correct way to represent most values.
When to choose JSON: API communication, data serialization, configuration that needs to be machine-generated. JSON is the most portable format.
When to choose YAML: Kubernetes, Docker Compose, Ansible, CI/CD pipelines. YAML supports advanced features like anchors and multi-document streams, though it is more complex to parse correctly.
Use Cases
Rust Developers — Validate Cargo.toml manifests, inspect Cargo.lock dependency trees with the tree view, and convert between TOML and JSON for tooling interoperability.
Python Developers — Validate pyproject.toml configurations for pip, Poetry, Hatch, and Ruff. Convert setup.cfg or setup.py configs to TOML format.
Hugo / Static Site — Validate and format Hugo config.toml site configuration files.
DevOps Engineers — Validate TOML-based tool configurations (Terraform, Starship prompt, gitconfig alternatives).
API Tooling — Convert JSON API responses or config payloads to TOML format for configuration files, or convert existing TOML configs to JSON for APIs that require JSON.
Privacy
All TOML processing — parsing, validation, formatting, minification, conversion, and tree rendering — runs entirely in your browser using JavaScript. No TOML or JSON content is ever transmitted to any server. Your configuration files, including any secrets, API keys, or database credentials, remain on your machine.
FAQ
Q: What version of the TOML spec does this support?
A: The parser implements TOML 1.0 features including all string types (basic, literal, multi-line basic, multi-line literal), integer formats (decimal, hex, octal, binary), floats (including inf and nan), datetime values, arrays, standard tables, inline tables, and array-of-tables. The _ underscore separator in numeric literals is supported.
Q: Why does Format remove my comments?
A: The Format operation normalizes TOML by round-tripping through the internal parser. Since the parsed value is a plain JavaScript object (comments are not part of the TOML data model), the re-serialized output does not include comments. Use Minify instead if you want to preserve the key-value structure while only removing comment lines.
Q: What happens to TOML datetime values when converting to JSON?
A: TOML datetime, date, and time values are converted to their string representations in JSON output (e.g., "2024-01-15T12:00:00Z"). JSON has no native datetime type, so this is the standard conversion approach.
Q: Can I convert JSON null to TOML?
A: No — TOML has no null type. When converting JSON to TOML, keys with null values are skipped. If you need a nullable value in TOML, use a boolean flag or an absent key as a convention.
Q: Can I use this to convert Cargo.lock to JSON?
A: Yes, this tool can convert any valid TOML file to JSON. However, Cargo.lock uses array-of-tables ([[package]]) extensively, which become JSON arrays as expected. The resulting JSON may be very large for complex projects.
Q: Does TOML support nested tables and arrays?
A: Yes. TOML supports arbitrary nesting of tables (objects) and arrays, including arrays of tables ([[...]]) which map to JSON arrays of objects. The tree view is useful for exploring deeply nested TOML structures.