---
title: "@std/toml"
description: "Parsing and serializing of TOML files"
jsr: jsr:@std/toml
pkg: toml
version: 1.0.11
generated: true
stability: stable
---
<!-- Autogenerated from JSR docs. Do not edit directly. -->

## Overview

<p><a href="https://jsr.io/@std/toml@1.0.11/doc/~/parse" rel="nofollow"><code>parse</code></a> and <a href="https://jsr.io/@std/toml@1.0.11/doc/~/stringify" rel="nofollow"><code>stringify</code></a> for handling
<a href="https://toml.io" rel="nofollow">TOML</a> encoded data.</p>
<p>Be sure to read the supported types as not every spec is supported at the
moment and the handling in TypeScript side is a bit different.</p>
<h2 id="supported-types-and-handling">
Supported types and handling</h2>
<ul>
<li> <a href="https://toml.io/en/latest#keys" rel="nofollow">Keys</a></li>
<li> <a href="https://toml.io/en/latest#string" rel="nofollow">String</a></li>
<li> <a href="https://toml.io/en/latest#string" rel="nofollow">Multiline String</a></li>
<li> <a href="https://toml.io/en/latest#string" rel="nofollow">Literal String</a></li>
<li> <a href="https://toml.io/en/latest#integer" rel="nofollow">Integer</a></li>
<li> <a href="https://toml.io/en/latest#float" rel="nofollow">Float</a></li>
<li> <a href="https://toml.io/en/latest#boolean" rel="nofollow">Boolean</a></li>
<li> <a href="https://toml.io/en/latest#offset-date-time" rel="nofollow">Offset Date-time</a></li>
<li> <a href="https://toml.io/en/latest#local-date-time" rel="nofollow">Local Date-time</a></li>
<li> <a href="https://toml.io/en/latest#local-date" rel="nofollow">Local Date</a></li>
<li> <a href="https://toml.io/en/latest#local-time" rel="nofollow">Local Time</a></li>
<li> <a href="https://toml.io/en/latest#table" rel="nofollow">Table</a></li>
<li> <a href="https://toml.io/en/latest#inline-table" rel="nofollow">Inline Table</a></li>
<li> <a href="https://toml.io/en/latest#array-of-tables" rel="nofollow">Array of Tables</a></li>
</ul>
<p><em>Supported with warnings see <a href="#Warning" rel="nofollow">Warning</a>.</em></p>
<h3 id="warning">
Warning</h3>
<h4 id="string">
String</h4>
<p>Due to the spec, there is no flag to detect regex properly in a TOML
declaration. So the regex is stored as string.</p>
<h4 id="integer">
Integer</h4>
<p>For <strong>Binary</strong> / <strong>Octal</strong> / <strong>Hexadecimal</strong> numbers, they are stored as string
to be not interpreted as Decimal.</p>
<h4 id="local-time">
Local Time</h4>
<p>Because local time does not exist in JavaScript, the local time is stored as a
string.</p>
<h4 id="array-of-tables">
Array of Tables</h4>
<p>At the moment only simple declarations like below are supported:</p>

```js
[[bin]]
name = "deno"
path = "cli/main.rs"

[[bin]]
name = "deno_core"
path = "src/foo.rs"

[[nib]]
name = "node"
path = "not_found"
```

<p>will output:</p>

```js
{
  "bin": [
    { "name": "deno", "path": "cli/main.rs" },
    { "name": "deno_core", "path": "src/foo.rs" }
  ],
  "nib": [{ "name": "node", "path": "not_found" }]
}
```

```js
import { parse, stringify } from "@std/toml";
import { assertEquals } from "@std/assert";

const obj = {
  bin: [
    { name: "deno", path: "cli/main.rs" },
    { name: "deno_core", path: "src/foo.rs" },
  ],
  nib: [{ name: "node", path: "not_found" }],
};

const tomlString = stringify(obj);
assertEquals(tomlString, `
[[bin]]
name = "deno"
path = "cli/main.rs"

[[bin]]
name = "deno_core"
path = "src/foo.rs"

[[nib]]
name = "node"
path = "not_found"
`);

const tomlObject = parse(tomlString);
assertEquals(tomlObject, obj);
```

### Add to your project

```sh
deno add jsr:@std/toml
```

<a href="https://jsr.io/@std/toml/doc" class="docs-cta jsr-cta">See all symbols in @std/toml on
<svg class="inline ml-1" viewBox="0 0 13 7" aria-hidden="true" height="20"><path d="M0,2h2v-2h7v1h4v4h-2v2h-7v-1h-4" fill="#083344"></path><g fill="#f7df1e"><path d="M1,3h1v1h1v-3h1v4h-3"></path><path d="M5,1h3v1h-2v1h2v3h-3v-1h2v-1h-2"></path><path d="M9,2h3v2h-1v-1h-1v3h-1"></path></g></svg></a>

<!-- custom:start -->
<!-- Add persistent custom content below. This section is preserved across generations. -->

<!-- custom:end -->
