TOML all the way down
Schemas are valid TOML documents and use the required .tosd filename extension.
TOML Schema describes structure, value types, reusable constraints, and common semantic relationships using TOML syntax itself.
TOML Schema is intentionally smaller than general-purpose schema systems. It focuses on the TOML value model and keeps schemas readable for people who already know TOML.
Schemas are valid TOML documents and use the required .tosd filename extension.
Define required fields, types, conditional branches, collections, unions, composition, sibling rules, uniqueness, defaults, and deprecations.
Java, Go, .NET, Python, Rust, and Node.js/TypeScript libraries validate examples and self-schema behavior in CI; Rust also exercises the canonical CLI end to end.
Open a .tosd file as a schema map, edit its properties,
and inspect the generated TOML without leaving the GitHub Copilot App.
The canonical tosd CLI validates TOML against an explicit
schema or follows the document's [toml-schema].location.
Release downloads support Linux x86_64 and arm64, Apple Silicon macOS,
and Windows x86_64.
curl --proto '=https' --tlsv1.2 -sSfL \
https://github.com/brunoborges/toml-schema/releases/download/rust-v1.0.0-rc.2/install-tosd.sh |
bash -s -- --version 1.0.0-rc.2
tosd validate config.tosd config.toml
A schema includes versioned metadata and describes the TOML document
under [elements]. Reusable shapes live under [types].
Each example pairs a schema fragment with the TOML it describes. The
schema fragments form one schema and are not standalone files.
Every schema document must contain [toml-schema] with a full SemVer version.
[toml-schema]
version = "1.0.0"
[toml-schema]
location = "config.tosd"
version = "1.0.0"
Each entry under [elements] maps to a TOML key, table, or nested value.
[elements.title]
type = "string"
[elements.database]
type = "table"
[elements.database.enabled]
type = "boolean"
title = "Example"
[database]
enabled = true
Arrays can validate homogeneous item types or reference reusable item schemas.
[elements.database.ports]
type = "array"
itemtype = "integer"
minlength = 1
[database]
ports = [8000, 8001]
Reusable [types] definitions keep repeated structures in one place.
[types.server]
type = "table"
[types.server.ip]
type = "string"
pattern = "^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$"
[types.server.role]
type = "string"
[servers.primary]
ip = "10.0.0.1"
role = "frontend"
Choose between reusable table shapes using a direct child value. Each branch can require its own fields and reject fields from the other shape.
[types.sqliteDatabase]
type = "table"
[types.sqliteDatabase.engine]
type = "string"
[types.sqliteDatabase.path]
type = "string"
[types.serverDatabase]
type = "table"
[types.serverDatabase.engine]
type = "string"
[types.serverDatabase.host]
type = "string"
[types.serverDatabase.port]
type = "integer"
[types.database]
if = { key = "engine", equals = "sqlite" }
then = "types.sqliteDatabase"
else = "types.serverDatabase"
[elements.storage]
type = "types.database"
optional = true
[storage]
engine = "postgresql"
host = "db.internal"
port = 5432
A collection validates values stored under user-defined keys, such as named servers or environments.
[elements.servers]
type = "collection"
itemtype = "types.server"
minlength = 1
[servers.primary]
ip = "10.0.0.1"
role = "frontend"
[servers.backup]
ip = "10.0.0.2"
role = "backend"
Values can be constrained with allowed values, numeric ranges, string lengths, or patterns.
[elements.environment]
type = "string"
allowedvalues = ["dev", "stage", "prod"]
[elements.retries]
type = "integer"
min = 0
max = 10
environment = "prod"
retries = 3
The language is built around three top-level tables: [toml-schema],
optional reusable [types], and required document [elements].
[toml-schema] declares SemVer language compatibility.type, itemtype, items, oneof, anyof, allof, then, and else select or compose built-in types and reusable [types] definitions.collection validates dynamically named values; keypattern can constrain their keys.oneof requires exactly one matching type; anyof requires at least one.if selects a reusable then or else definition from a direct child's parsed value.dependentrequired, mutuallyexclusive, and exactlyone constrain direct sibling presence.default is non-mutating metadata; deprecated produces warnings without invalidating a document.itemtype validates homogeneous array and collection members; items defines positional arrays..tosd and the registered application/toml media type.The repository includes implementation work for multiple ecosystems and a shared conformance expectation for schema validation.
Uses Tomlj to parse TOML and validates documents against .tosd schemas.
Uses go-toml and supports explicit schema validation and schema-location lookup.
Uses Tomlyn to parse TOML and validates documents against .tosd schemas.
Uses the standard-library tomllib parser and supports schema validation and schema-location lookup.
Uses the Rust toml crate and provides validation, schema discovery, and schema extraction commands.
Uses smol-toml and provides validation, schema discovery, and schema extraction through an ESM API.