Syntax
TOML's syntax primarily consists ofkey = value
pairs, ection names/code>, and #
(for comments). TOML's syntax somewhat resembles that of . INI files, but it includes a formal specification,
whereas the INI file format suffers from many competing variants.
Its specification includes a list of supported data types: String, Integer, Float, Boolean, Datetime, Array, and Table.
Example
# This is a TOML document.
title = "TOML Example"
wnername = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00 # First class dates
atabaseserver = "192.168.1.1"
ports = 8000, 8001, 8002 connection_max = 5000
enabled = true
ervers
# Indentation (tabs and/or spaces) is allowed but not required
ervers.alpha ip = "10.0.0.1"
dc = "eqdc10"
ervers.beta ip = "10.0.0.2"
dc = "eqdc10"
lientsdata = ["gamma",_"delta"_[1,_2.html" ;"title="gamma",_"delta".html" ;"title="["gamma", "delta"">["gamma", "delta" [1, 2">gamma",_"delta".html" ;"title="["gamma", "delta"">["gamma", "delta" [1, 2]
# Line breaks are OK when inside arrays
hosts = [
"alpha",
"omega"
]
Use cases
TOML is used in a variety of settings (some related to its creator), such as:
* Static site generators like Jekyll and Hugo
* Continuous integration on e.g. GitHub and GitLab
Python
programming language
programming language
Comparison to other formats
The following table draws on th
TOML specification
to make a comparison to other popular configuration formats.
Criticism
Since its first release TOML has received several critiques. The following is not a consensus. The HitchDev lists the following points as problematic in TOML:
* TOML is verbose; it is not DRY and it is syntactically noisy
* TOML's hierarchies are difficult to infer from syntax alone
* Overcomplication: Like YAML, TOML has too many features
* In TOML the syntax determines the data types ("syntax typing")
Th
libconfini
project has since released a more extensive critique of TOML from the INI perspective, listing the following points (among others) as problematic:
* TOML lets the configuration file decide about data types (syntax typing), when ''de facto'' it is the client application that decides. Any mismatching type will be either ignored or converted to the expected type (depending on the parser) anyway
* TOML re-introduces what human-friendly languages normally try to get rid of: a verbose syntax and the necessity of using quotes for strings
* TOML syntax is always case-sensitive In computers, case sensitivity defines whether uppercase and lowercase letters are treated as distinct (case-sensitive) or equivalent (case-insensitive). For instance, when users interested in learning about dogs search an e-book, "dog" and "Dog" a ...
, despite the fact that there are situations where configuration files ''must'' be case-insensitive (as, for instance, configuration files that map a FAT32 filesystem or HTML tags)
* TOML uses square brackets for arrays even though square brackets are already reserved for table names; furthermore any special syntax for arrays brings the language back to syntax typing
* A TOML table must be populated in a single step; merging multiple TOML files is problematic
* TOML arbitrarily introduces a syntax for dates
* TOML allows (but discourages) the empty string
In formal language theory, the empty string, or empty word, is the unique string of length zero.
Formal theory
Formally, a string is a finite, ordered sequence of characters such as letters, digits or spaces. The empty string is the special cas ...
as a key
* TOML's quoting rules introduce confusion between actual strings (free content) and enumeration labels (i.e. choices within closed sets of options)
* TOML's rules cannot be inferred from the content, therefore editing a TOML file requires prior knowledge of the language
* TOML is backward-incompatible with INI
See also
* INI file
* JSON
JSON (JavaScript Object Notation, pronounced ; also ) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other ser ...
- from JavaScript ecosystem
* Recfiles
recfiles is a file format for human-editable, plain text databases.
Databases using this file format can be edited using any text editor. recfiles allow for basic relational database operations, typing, auto-incrementing, as well as a simple join ...
* YAML
YAML ( and ) (''see '') is a human-readable data-serialization language. It is commonly used for configuration files and in applications where data is being stored or transmitted. YAML targets many of the same communications applications as Exte ...
* HOCON
HOCON, or Human-Optimized Config Object Notation is a format for human-readable data, and a superset of JSON.
Uses of HOCON
* It is primarily used in conjunction with the Play framework, and is developed by Lightbend.
* It is also supported ...
References
External links
*
*
{{Data Exchange
Computer file formats
Configuration files
Lightweight markup languages
Markup languages