CINXE.COM
Schema Validation for TOML | JSON Schema Everywhere
<!DOCTYPE html> <html lang="en"><head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"><!-- Begin Jekyll SEO tag v2.5.0 --> <title>Schema Validation for TOML | JSON Schema Everywhere</title> <meta name="generator" content="Jekyll v3.7.4" /> <meta property="og:title" content="Schema Validation for TOML" /> <meta property="og:locale" content="en_US" /> <meta name="description" content="Tracking schema validation and editor support of data description languages." /> <meta property="og:description" content="Tracking schema validation and editor support of data description languages." /> <link rel="canonical" href="https://json-schema-everywhere.github.io/toml" /> <meta property="og:url" content="https://json-schema-everywhere.github.io/toml" /> <meta property="og:site_name" content="JSON Schema Everywhere" /> <script type="application/ld+json"> {"@type":"WebPage","headline":"Schema Validation for TOML","url":"https://json-schema-everywhere.github.io/toml","description":"Tracking schema validation and editor support of data description languages.","@context":"http://schema.org"}</script> <!-- End Jekyll SEO tag --> <link rel="stylesheet" href="/assets/main.css"><link type="application/atom+xml" rel="alternate" href="https://json-schema-everywhere.github.io/feed.xml" title="JSON Schema Everywhere" /><script> if(!(window.doNotTrack === "1" || navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1")) { (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-101483402-1', 'auto'); ga('send', 'pageview'); } </script> </head> <body><header class="site-header" role="banner"> <div class="wrapper"> <a class="site-title" href="/">JSON Schema Everywhere</a> <nav class="site-nav"> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger"> <span class="menu-icon"> <svg viewBox="0 0 18 15" width="18px" height="15px"> <path fill="#424242" d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.031C17.335,0,18,0.665,18,1.484L18,1.484z"/> <path fill="#424242" d="M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0c0-0.82,0.665-1.484,1.484-1.484 h15.031C17.335,6.031,18,6.696,18,7.516L18,7.516z"/> <path fill="#424242" d="M18,13.516C18,14.335,17.335,15,16.516,15H1.484C0.665,15,0,14.335,0,13.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.031C17.335,12.031,18,12.696,18,13.516L18,13.516z"/> </svg> </span> </label> <div class="trigger"> <a class="page-link" href="/cson">CSON</a> <a class="page-link" href="/hjson">Hjson</a> <a class="page-link" href="/json5">JSON5</a> <a class="page-link" href="/toml">TOML</a> <a class="page-link" href="/yaml">YAML</a> </div> </nav> </div> </header> <main class="page-content" aria-label="Content"> <div class="wrapper"> <article class="post"> <header class="post-header"> <a href=https://github.com/toml-lang/toml><img style="float:right;width:160px" src="assets/logos/toml.svg"></a> <h1 class="post-title">Schema Validation for TOML</h1> </header> <div class="post-content"> <p> JSON Schema can be used to validate TOML documents. <a href=https://github.com/toml-lang/toml>Tom's Obvious, Minimal Language (TOML)</a> is a minimal language with growing popularity that is largely compatible with JSON, though more restrictive. There is a proposal for a TOML-specific schema language, which may be a viable option in the future. However, until such a proposal gains traction and is implemented, JSON Schema remains the most available option for validating TOML files. </p> <input id="toggle" type="checkbox" style="align:right" unchecked><label style="align:right">Check to see examples of JSON and TOML documents</label> <div id="expand"> <div class="block" style="float:left;width:50%;"> <h3>JSON</h3> <div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w"> </span><span class="s2">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="s2">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"An ice sculpture"</span><span class="p">,</span><span class="w"> </span><span class="s2">"price"</span><span class="p">:</span><span class="w"> </span><span class="mf">12.5</span><span class="p">,</span><span class="w"> </span><span class="s2">"tags"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="s2">"cold"</span><span class="p">,</span><span class="w"> </span><span class="s2">"ice"</span><span class="w"> </span><span class="p">],</span><span class="w"> </span><span class="s2">"dimensions"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s2">"length"</span><span class="p">:</span><span class="w"> </span><span class="mi">7</span><span class="p">,</span><span class="w"> </span><span class="s2">"width"</span><span class="p">:</span><span class="w"> </span><span class="mi">12</span><span class="p">,</span><span class="w"> </span><span class="s2">"height"</span><span class="p">:</span><span class="w"> </span><span class="mf">9.5</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="s2">"warehouseLocation"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="s2">"latitude"</span><span class="p">:</span><span class="w"> </span><span class="mf">-78.75</span><span class="p">,</span><span class="w"> </span><span class="s2">"longitude"</span><span class="p">:</span><span class="w"> </span><span class="mf">20.4</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"> </span></code></pre></div></div> </div> <div class="block" style="float:right;width:50%;"> <h3>TOML</h3> <div class="language-toml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="py">id</span> <span class="p">=</span> <span class="mf">2.0</span> <span class="py">name</span> <span class="p">=</span> <span class="s">"An ice sculpture"</span> <span class="py">price</span> <span class="p">=</span> <span class="mf">12.5</span> <span class="py">tags</span> <span class="p">=</span> <span class="p">[</span><span class="s">"cold"</span><span class="p">,</span> <span class="s">"ice"</span><span class="p">]</span> <span class="nn">[dimensions]</span> <span class="py">length</span> <span class="p">=</span> <span class="mf">7.0</span> <span class="py">width</span> <span class="p">=</span> <span class="mf">12.0</span> <span class="py">height</span> <span class="p">=</span> <span class="mf">9.5</span> <span class="nn">[warehouseLocation]</span> <span class="py">latitude</span> <span class="p">=</span> <span class="mi">-78</span><span class="mf">.75</span> <span class="py">longitude</span> <span class="p">=</span> <span class="mf">20.4</span> </code></pre></div></div> </div> <small>Example JSON from the <a href="http://json-schema.org/example1.html#set-of-products">JSON Schema</a> website.</small> </div> <br> <h2 id="editors">Editor Support</h2> <p>No editors supporting JSON Schema validation of TOML documents are known.</p> <h2 id="validators">Tools and Libraries</h2> <ul> <li><a href="https://www.npmjs.com/package/pajv">Polyglottal JSON Schema Validator</a> - Written in JavaScript. Released under the MIT license. <ul> <li>Polyglottal JSON Schema Validator (pajv) is a command line utility that can be used to validate data in numerous formats against a JSON Schema.</li> </ul> </li> </ul> <h2 id="alternatives">Alternatives</h2> <ul> <li><a href="https://github.com/toml-lang/toml/pull/116">Tom's Obvious Liuggio Scheme (TOLS)</a> <ul> <li>Proposed specification without recent activity</li> </ul> <ul> <li>No implementations are known to exist</li> </ul> </ul> </ul> </div> </article> </div> </main><footer class="site-footer"> <div class="wrapper"> <div class="footer-col-wrapper"> <div class="footer-col footer-col-1"> <h2 class="footer-heading"><a href="/">JSON Schema Everywhere</a></h2> <ul class="contact-list"> <li> Tracking schema validation and editor support of data description languages. </li> <a href="https://github.com/json-schema-everywhere"><span class="icon icon--github"><svg viewBox="0 0 16 16" width="16px" height="16px"><path fill="#828282" d="M7.999,0.431c-4.285,0-7.76,3.474-7.76,7.761 c0,3.428,2.223,6.337,5.307,7.363c0.388,0.071,0.53-0.168,0.53-0.374c0-0.184-0.007-0.672-0.01-1.32 c-2.159,0.469-2.614-1.04-2.614-1.04c-0.353-0.896-0.862-1.135-0.862-1.135c-0.705-0.481,0.053-0.472,0.053-0.472 c0.779,0.055,1.189,0.8,1.189,0.8c0.692,1.186,1.816,0.843,2.258,0.645c0.071-0.502,0.271-0.843,0.493-1.037 C4.86,11.425,3.049,10.76,3.049,7.786c0-0.847,0.302-1.54,0.799-2.082C3.768,5.507,3.501,4.718,3.924,3.65 c0,0,0.652-0.209,2.134,0.796C6.677,4.273,7.34,4.187,8,4.184c0.659,0.003,1.323,0.089,1.943,0.261 c1.482-1.004,2.132-0.796,2.132-0.796c0.423,1.068,0.157,1.857,0.077,2.054c0.497,0.542,0.798,1.235,0.798,2.082 c0,2.981-1.814,3.637-3.543,3.829c0.279,0.24,0.527,0.713,0.527,1.437c0,1.037-0.01,1.874-0.01,2.129 c0,0.208,0.14,0.449,0.534,0.373c3.081-1.028,5.302-3.935,5.302-7.362C15.76,3.906,12.285,0.431,7.999,0.431z"/></svg> </span><span class="username">json-schema-everywhere</span></a> </ul> <ul class="social-media-list"> </ul> </div> <div class="footer-col footer-col-2"> </div> <div class="footer-col footer-col-3"> <p> The content of this site is licensed under the <a href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 License</a>.<br> All logos and trademarks are property of their respective owners.<br> <a href="https://github.com/json-schema-everywhere/json-schema-everywhere.github.io/"><small>Hosted on GitHub</small></a> </p> </div> </div> </div> </footer> </body> </html>