CINXE.COM
TOML: Tom's Obvious Minimal Language
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <title>TOML: Tom's Obvious Minimal Language</title> <link rel="icon" type="image/png" href="/favicon.png" /> <link rel="stylesheet" href="/stylesheets/application.css" /> <script type="text/javascript" src="/javascripts/application.js"></script> </head> <body class="bg-white text-gray-900 font-sans antialiased" data-controller="application"> <header class="items-center bg-white shadow fixed left-0 right-0 z-30 border-t-4 border-orange-800"> <div class="flex flex-1 items-center p-3"> <a class="flex items-center font-mono tracking-tighter" href="index"> <svg class="w-10 mr-2" viewBox="0 0 128 128" xmlns="http://www.w3.org/2000/svg"> <g> <polygon class="fill-current text-orange-800" points="99.2359551 -7.08546829e-15 99.2359551 14.3820225 112.179775 14.3820225 112.179775 113.617978 99.2359551 113.617978 99.2359551 128 128 128 128 0" ></polygon> <polygon class="fill-current text-black" points="32.3595506 41.7078652 32.3595506 25.8876404 95.6404494 25.8876404 95.6404494 41.7078652 71.9101124 41.7078652 71.9101124 110.741573 56.0898876 110.741573 56.0898876 41.7078652" ></polygon> <polygon class="fill-current text-orange-800" points="28.7640449 0 28.7640449 14.3820225 15.8202247 14.3820225 15.8202247 113.617978 28.7640449 113.617978 28.7640449 128 0 128 0 0" ></polygon> </g> </svg> <pre class="font-mono font-bold text-sm">v1.0.0</pre> </a> </div> <nav class="absolute top-0 right-0 mt-3 w-full md:w-auto py-1 px-2"> <ul class="flex justify-end items-start text-orange-900 text-sm text-center"> <li class="md:w-1/2 md:w-auto mx-2 px-2 bg-white border border-orange-300 rounded"> <div class="w-24"> <a href="#" class="block py-1 px-1" data-action="click->application#showVersions" data-target="application.versionsLink" >Full spec</a > <ul class="hidden block my-2 px-1 text-sm leading-loose" data-target="application.versions"> <li data-target="application.version" data-version="v1.0.0"><a href='/en/v1.0.0'>v1.0.0</a></li> <li data-target="application.version" data-version="v1.0.0-rc.3"><a href='/en/v1.0.0-rc.3'>v1.0.0-rc.3</a></li> <li data-target="application.version" data-version="v1.0.0-rc.2"><a href='/en/v1.0.0-rc.2'>v1.0.0-rc.2</a></li> <li data-target="application.version" data-version="v1.0.0-rc.1"><a href='/en/v1.0.0-rc.1'>v1.0.0-rc.1</a></li> <li data-target="application.version" data-version="v0.5.0"><a href='/en/v0.5.0'>v0.5.0</a></li> <li data-target="application.version" data-version="v0.4.0"><a href='/en/v0.4.0'>v0.4.0</a></li> <li data-target="application.version" data-version="v0.3.1"><a href='/en/v0.3.1'>v0.3.1</a></li> <li data-target="application.version" data-version="v0.3.0"><a href='/en/v0.3.0'>v0.3.0</a></li> <li data-target="application.version" data-version="v0.2.0"><a href='/en/v0.2.0'>v0.2.0</a></li> <li data-target="application.version" data-version="v0.1.0"><a href='/en/v0.1.0'>v0.1.0</a></li> </ul> </div> </li> <li class="md:w-1/2 md:w-auto mx-2 px-2 bg-white border border-orange-300 rounded"> <div class="w-16 md:w-24"> <a href="#" class="block py-1 px-1" data-action="click->application#showLanguages" data-target="application.languagesLink" >Language</a > <ul class="hidden my-2 text-sm leading-loose text-center" data-target="application.languages" > <li data-target="application.language" data-language="cn"><a href='/cn/v1.0.0'>简体中文</a></li> <li data-target="application.language" data-language="en"><a href='/en/v1.0.0'>English</a></li> <li data-target="application.language" data-language="fr"><a href='/fr/v1.0.0'>Français</a></li> <li data-target="application.language" data-language="ja"><a href='/ja/v1.0.0'>日本語</a></li> <li data-target="application.language" data-language="ko"><a href='/ko/v1.0.0'>한국어</a></li> <li data-target="application.language" data-language="pl"><a href='/pl/v1.0.0'>Polski</a></li> <li data-target="application.language" data-language="pt"><a href='/pt/v1.0.0'>Português</a></li> </ul> </div> </li> <li class="hidden sm:block mt-1 mx-2"> <a class="block w-6" href="https://github.com/toml-lang/toml" title="Go to TOML's GitHub repo"> <svg viewBox="0 0 32 32" class="transition duration-200 fill-current text-orange-400 hover:text-orange-700" xmlns="http://www.w3.org/2000/svg"> <path d="M15.9995 -8.73473e-07C12.198 -0.00275596 8.5196 1.34817 5.62346 3.81077C2.72731 6.27336 0.802616 9.6867 0.194194 13.4393C-0.414229 17.1919 0.333374 21.0385 2.30307 24.29C4.27276 27.5415 7.33584 29.9855 10.9435 31.184C11.7435 31.344 12.0315 30.832 12.0315 30.416L12.0155 27.696C7.56755 28.656 6.62355 25.552 6.62355 25.552C5.88755 23.696 4.84755 23.2 4.84755 23.2C3.40755 22.208 4.95955 22.24 4.95955 22.24C6.55955 22.352 7.40755 23.888 7.40755 23.888C8.84755 26.32 11.1515 25.616 12.0635 25.216C12.2235 24.176 12.6235 23.472 13.0715 23.072C9.51955 22.672 5.79155 21.296 5.79155 15.168C5.79155 13.408 6.41555 11.984 7.43955 10.864C6.95565 9.4866 7.01283 7.97684 7.59955 6.64C7.59955 6.64 8.94355 6.208 11.9995 8.272C14.6192 7.56384 17.3799 7.56384 19.9995 8.272C23.0555 6.192 24.3995 6.64 24.3995 6.64C25.2795 8.832 24.7195 10.48 24.5595 10.864C25.5835 11.984 26.2075 13.424 26.2075 15.168C26.2075 21.312 22.4635 22.656 18.8955 23.056C19.4715 23.552 19.9835 24.528 19.9835 26.016L19.9675 30.416C19.9675 30.832 20.2555 31.344 21.0715 31.184C24.6806 29.985 27.7445 27.5398 29.7141 24.2866C31.6837 21.0334 32.4302 17.185 31.8197 13.4314C31.2092 9.67772 29.2816 6.26427 26.3825 3.80296C23.4835 1.34165 19.8025 -0.00657403 15.9995 -8.73473e-07Z" /> </svg> </a> </li> </ul> </nav> </header> <main class=""> <div class="bg-orange-100 lg:flex"> <section class="pt-32 pb-8 lg:pt-64 lg:flex-1 lg:w-1/2"> <div class="px-4 lg:px-8"> <div class="flex items-end"> <svg class="w-24 mr-2 lg:w-32" viewBox="0 0 128 128" xmlns="http://www.w3.org/2000/svg"> <g> <polygon class="fill-current text-orange-800" points="99.2359551 -7.08546829e-15 99.2359551 14.3820225 112.179775 14.3820225 112.179775 113.617978 99.2359551 113.617978 99.2359551 128 128 128 128 0" ></polygon> <polygon class="fill-current text-black" points="32.3595506 41.7078652 32.3595506 25.8876404 95.6404494 25.8876404 95.6404494 41.7078652 71.9101124 41.7078652 71.9101124 110.741573 56.0898876 110.741573 56.0898876 41.7078652" ></polygon> <polygon class="fill-current text-orange-800" points="28.7640449 0 28.7640449 14.3820225 15.8202247 14.3820225 15.8202247 113.617978 28.7640449 113.617978 28.7640449 128 0 128 0 0" ></polygon> </g> </svg> <div class="font-mono leading-tight"> <h1 class="font-bold text-3xl lg:text-4xl">TOML</h1> <h2 class="text-xs text-orange-800 lg:text-base"> [Tom's Obvious Minimal Language] </h2> </div> </div> <h3 class="mt-12 mb-4 font-semibold text-4xl text-left text-orange-900 leading-none tracking-tight" > A config file format <br class="md:hidden" />for humans. </h3> <p class="hidden mt-8 text-xl text-yellow-800 lg:block"> TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics. TOML is designed to map unambiguously to a hash table. TOML should be easy to parse into data structures in a wide variety of languages. </p> </div> </section> <section class="lg:flex-1 lg:p-24 lg:pb-0 lg:-mb-8"> <pre class="code my-0 toml" data-controller="snippet" data-snippet-copy="false"><code># This is a TOML document title = "TOML Example" [owner] name = "Tom Preston-Werner" dob = 1979-05-27T07:32:00-08:00 [database] enabled = true ports = [ 8000, 8001, 8002 ] data = [ ["delta", "phi"], [3.14] ] temp_targets = { cpu = 79.5, case = 72.0 } [servers] [servers.alpha] ip = "10.0.0.1" role = "frontend" [servers.beta] ip = "10.0.0.2" role = "backend"</code></pre> </section> </div> <section class="mt-16 mb-16 lg:p-4"> <dl class="lg:flex lg:items-start"> <div class="flex-1 p-4"> <dt class="marketing-title"> <div class="bg-orange-600 rounded-full inline-block p-2 mr-2 align-middle"> <svg class="w-6 h-6 fill-current text-white" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" > <path d="M9 12A5 5 0 1 1 9 2a5 5 0 0 1 0 10zm0-2a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm7 11a1 1 0 0 1-2 0v-2a3 3 0 0 0-3-3H7a3 3 0 0 0-3 3v2a1 1 0 0 1-2 0v-2a5 5 0 0 1 5-5h4a5 5 0 0 1 5 5v2zm1-5a1 1 0 0 1 0-2 5 5 0 0 1 5 5v2a1 1 0 0 1-2 0v-2a3 3 0 0 0-3-3zm-2-4a1 1 0 0 1 0-2 3 3 0 0 0 0-6 1 1 0 0 1 0-2 5 5 0 0 1 0 10z" /> </svg> </div> TOML prioritizes humans </dt> <dd class="text-gray-600 ml-13"> <p class="ml-1">TOML aims to be a minimal configuration file format that:</p> <ul class="mt-2 ml-1 leading-relaxed"> <li class="leading-snug"> <span class="font-bold">is easy to read</span> due to obvious semantics </li> <li class="leading-snug mt-2"> <span class="font-bold">maps unambiguously</span> to a hash table </li> <li class="leading-snug mt-2"> <span class="font-bold">is easy to parse</span> into data structures in a wide variety of languages </li> </ul> </dd> </div> <div class="flex-1 p-4"> <dt class="mt-12 marketing-title lg:mt-0"> <div class="bg-orange-600 rounded-full inline-block p-2 mr-2 align-middle"> <svg class="w-6 h-6 fill-current text-white" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" > <path d="M5 3h4a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2zm0 2v4h4V5H5zm10-2h4a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2zm0 2v4h4V5h-4zM5 13h4a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4c0-1.1.9-2 2-2zm0 2v4h4v-4H5zm10-2h4a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-4c0-1.1.9-2 2-2zm0 2v4h4v-4h-4z" /> </svg> </div> TOML has useful native types </dt> <dd class="text-gray-600 ml-12"> <ul class="mt-1 ml-1 leading-relaxed"> <li class="flex items-center"> <svg class="w-4 h-4 mr-2 fill-current text-gray-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" > <path d="M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm1-9h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 0v-2H9a1 1 0 0 1 0-2h2V9a1 1 0 0 1 2 0v2z" /> </svg> <span>Key/Value Pairs</span> </li> <li class="flex items-center"> <svg class="w-4 h-4 mr-2 fill-current text-gray-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" > <path d="M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm1-9h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 0v-2H9a1 1 0 0 1 0-2h2V9a1 1 0 0 1 2 0v2z" /> </svg> <span>Arrays</span> </li> <li class="flex items-center"> <svg class="w-4 h-4 mr-2 fill-current text-gray-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" > <path d="M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm1-9h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 0v-2H9a1 1 0 0 1 0-2h2V9a1 1 0 0 1 2 0v2z" /> </svg> <span>Tables</span> </li> <li class="flex items-center"> <svg class="w-4 h-4 mr-2 fill-current text-gray-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" > <path d="M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm1-9h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 0v-2H9a1 1 0 0 1 0-2h2V9a1 1 0 0 1 2 0v2z" /> </svg> <span>Inline tables</span> </li> <li class="flex items-center"> <svg class="w-4 h-4 mr-2 fill-current text-gray-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" > <path d="M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm1-9h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 0v-2H9a1 1 0 0 1 0-2h2V9a1 1 0 0 1 2 0v2z" /> </svg> <span>Arrays of tables</span> </li> <li class="flex items-center"> <svg class="w-4 h-4 mr-2 fill-current text-gray-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" > <path d="M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm1-9h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 0v-2H9a1 1 0 0 1 0-2h2V9a1 1 0 0 1 2 0v2z" /> </svg> <span>Integers & Floats</span> </li> <li class="flex items-center"> <svg class="w-4 h-4 mr-2 fill-current text-gray-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" > <path d="M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm1-9h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 0v-2H9a1 1 0 0 1 0-2h2V9a1 1 0 0 1 2 0v2z" /> </svg> <span>Booleans</span> </li> <li class="flex items-center"> <svg class="inline-block w-4 h-4 mt-px mr-2 fill-current text-gray-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" > <path d="M12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm1-9h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 0v-2H9a1 1 0 0 1 0-2h2V9a1 1 0 0 1 2 0v2z" /> </svg> <span>Dates & Times, with optional offsets</span> </li> </ul> </dd> </div> <div class="flex-1 p-4"> <dt class="mt-12 marketing-title lg:mt-0"> <div class="bg-orange-600 rounded-full inline-block p-2 mr-2 align-middle"> <svg class="w-6 h-6 fill-current text-white" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" > <path d="M4.06 13a8 8 0 0 0 5.18 6.51A18.5 18.5 0 0 1 8.02 13H4.06zm0-2h3.96a18.5 18.5 0 0 1 1.22-6.51A8 8 0 0 0 4.06 11zm15.88 0a8 8 0 0 0-5.18-6.51A18.5 18.5 0 0 1 15.98 11h3.96zm0 2h-3.96a18.5 18.5 0 0 1-1.22 6.51A8 8 0 0 0 19.94 13zm-9.92 0c.16 3.95 1.23 7 1.98 7s1.82-3.05 1.98-7h-3.96zm0-2h3.96c-.16-3.95-1.23-7-1.98-7s-1.82 3.05-1.98 7zM12 22a10 10 0 1 1 0-20 10 10 0 0 1 0 20z" /> </svg> </div> TOML is widely supported </dt> <dd class="text-gray-600 ml-13"> <p class="ml-1"> TOML already has implementations in most of the most popular programming languages in use today: C, C#, C++, Clojure, Dart, Elixir, Erlang, Go, Haskell, Java, JavaScript, Lua, Objective-C, Perl, PHP, Python, Ruby, Rust, Scala, Swift, … <a class="underline" href="https://github.com/toml-lang/toml/wiki">and plenty more</a>. </p> </dd> </div> </dl> </section> <section class="bg-orange-100 text-orange-800 mt-8 pb-8"> <header class=""> <h2 class="py-4 text-2xl px-4 font-semibold tracking-tight bg-orange-800 text-left text-orange-100 lg:py-8 lg:text-center lg:text-4xl" > A Quick Tour of TOML </h2> </header> <div class="lg:flex"> <div class="lg:flex-1 lg:ml-16 lg:mr-8"> <section class="mt-8"> <div class="tour-text"> <h3 class="feature-title">Comments</h3> <p class="">TOML thinks all config files should support comments.</p> </div> <pre class="code toml" data-controller="snippet" data-snippet-copy="false"><code># This is a TOML comment # This is a multiline # TOML comment</code></pre> </section> <section class="mt-12"> <div class="tour-text"> <h3 class="feature-title">Powerful Strings</h3> <p> There are four ways to express strings: basic, multi-line basic, literal, and multi-line literal. <span class="font-bold">Basic strings</span> are surrounded by quotation marks: </p> </div> <pre class="code toml" data-controller="snippet" data-snippet-copy="false"><code>str1 = "I'm a string." str2 = "You can \"quote\" me." str3 = "Name\tJos\u00E9\nLoc\tSF."</code></pre> <p class="tour-text"> <span class="font-bold">Multi-line basic strings</span> are surrounded by three quotation marks on each side and allow newlines. Include a line ending backslash to automatically trim whitespace preceeding any non-whitespace characters: </p> <pre class="code toml" data-controller="snippet" data-snippet-copy="false"><code>str1 = """ Roses are red Violets are blue""" str2 = """\ The quick brown \ fox jumps over \ the lazy dog.\ """</code></pre> <p class="tour-text"> <code class="font-mono font-bold text-sm">str2</code> becomes <code class="font-mono font-bold text-sm" >"The quick brown fox jumps over the lazy dog."</code > (a single sentence with no line breaks). </p> <p class="mt-8 tour-text"> <span class="font-bold">Literal strings</span> are surrounded by single quotes. No escaping is performed so what you see is what you get: </p> <pre class="code toml" data-controller="snippet" data-snippet-copy="false"><code>path = 'C:\Users\nodejs\templates' path2 = '\\User\admin$\system32' quoted = 'Tom "Dubs" Preston-Werner' regex = '<\i\c*\s*>'</code></pre> <p class="tour-text"> Since there is no escaping, there is no way to write a single quote inside a literal string enclosed by single quotes. That's where <span class="font-bold">multi-line literal strings</span> come in: </p> <pre class="code toml" data-controller="snippet" data-snippet-copy="false" ><code>re = '''I [dw]on't need \d{2} apples''' lines = ''' The first newline is trimmed in raw strings. All other whitespace is preserved. '''</code></pre> </section> </div> <div class="lg:flex-1 lg:ml-8 lg:mr-16"> <section class="mt-12 lg:mt-8"> <div class="tour-text"> <h3 class="feature-title">Numbers</h3> <p class="text-orange-800"> Integers, floats, infinity, and even NaN are all supported. You can use scientific notation and even thousands separators. </p> </div> <pre class="code toml" data-controller="snippet" data-snippet-copy="false"><code># integers int1 = +99 int2 = 42 int3 = 0 int4 = -17 # hexadecimal with prefix `0x` hex1 = 0xDEADBEEF hex2 = 0xdeadbeef hex3 = 0xdead_beef # octal with prefix `0o` oct1 = 0o01234567 oct2 = 0o755 # binary with prefix `0b` bin1 = 0b11010110 # fractional float1 = +1.0 float2 = 3.1415 float3 = -0.01 # exponent float4 = 5e+22 float5 = 1e06 float6 = -2E-2 # both float7 = 6.626e-34 # separators float8 = 224_617.445_991_228 # infinity infinite1 = inf # positive infinity infinite2 = +inf # positive infinity infinite3 = -inf # negative infinity # not a number not1 = nan not2 = +nan not3 = -nan </code></pre> </section> <section class="mt-12"> <div class="tour-text"> <h3 class="feature-title">Dates and Times</h3> <p class="text-orange-800"> TOML features support for dates, times, and datetimes with and without offsets. </p> </div> <pre class="code toml" data-controller="snippet" data-snippet-copy="false"><code># offset datetime odt1 = 1979-05-27T07:32:00Z odt2 = 1979-05-27T00:32:00-07:00 odt3 = 1979-05-27T00:32:00.999999-07:00 # local datetime ldt1 = 1979-05-27T07:32:00 ldt2 = 1979-05-27T00:32:00.999999 # local date ld1 = 1979-05-27 # local time lt1 = 07:32:00 lt2 = 00:32:00.999999</code></pre> </section> </div> </div> </section> <section class="lg:flex bg-white"> <div class="pt-12 pb-16 px-8 text-center border-orange-100 border-b-2 lg:flex-1 lg:py-32 lg:border-r-2" > <h3 class="text-2xl font-bold lg:text-3xl">More Spec</h3> <p class="text-gray-600"> <strong>TOML</strong> supports even more native types and syntax, read all about it: </p> <div class="mt-4"> <a class="button" href="latest">Read the full spec</a> </div> </div> <div class="pt-12 pb-16 px-8 text-center lg:flex-1 lg:py-32"> <h3 class="text-2xl font-bold lg:text-3xl">Start coding</h3> <p class="text-gray-600"> <strong>TOML</strong> is already implemented in over 40 programming languages: </p> <div class="mt-4"> <a class="button" href="https://github.com/toml-lang/toml/wiki">Find a library</a> </div> </div> </section> </main> <footer class="bg-orange-900 text-orange-100 text-center text-sm p-4"> Created by <a class="underline" href="https://tom.preston-werner.com/">Tom Preston-Werner</a> <br /> <span class="font-mono font-bold">TOML</span> is released under the <a class="underline" href="https://github.com/toml-lang/toml/blob/master/LICENSE" >MIT License</a > </footer> </body> </html>