Articles
Published · November 18, 2026

TOML Tables and Arrays of Tables: What Double Brackets Mean

In TOML, [table] defines one table and [[table]] adds another item to an array of tables. Here is how the headers work, how sub-tables attach, and which mistakes cause errors.

Also in: Español中文हिन्दी

A TOML header in single brackets, like [server], defines one table. A header in double brackets, like [[server]], adds one more item to a list of tables. That one extra pair of brackets is the whole difference, and it is the reason Cargo.toml, pyproject.toml, and hugo.toml files look the way they do.

TOML was created by Tom Preston-Werner and first released in 2013, and it is now a common choice for config files in Rust, Python, and Hugo projects, according to Wikipedia. If you are still deciding on a format, see choosing between JSON, YAML, and TOML. This one is for the moment you already have a TOML file open and the brackets look like a typo.

Single brackets: one table

Per the TOML v1.0.0 specification, a table is a collection of key/value pairs, defined by a header with square brackets on a line by itself. Every key under the header belongs to that table until the next header or the end of the file.

[database]
server = "192.168.1.1"
port = 5432

[servers.alpha]
ip = "10.0.0.1"

A few details that save time:

  • A dot in the header nests tables. [servers.alpha] is a table named alpha inside a table named servers.
  • You don't have to write the parent first. The spec says a header like [x.y.z.w] is valid on its own, and the parent tables exist implicitly.
  • Whitespace around the name is ignored, and so is indentation. [ d.e.f ] means the same as [d.e.f]. The spec's own best-practice example is the tight form.
  • An empty table is fine. It just has no keys.
  • Keys at the top of the file, before any header, belong to the root table. The root table has no name and can't be moved.

Double brackets: an array of tables

A header with the name in double brackets defines an array of tables. Each time the header appears, it creates a new table and appends it to the array, in the order they appear in the file. Here is the spec's example:

[[products]]
name = "Hammer"
sku = 738594937

[[products]]  # an empty table within the array

[[products]]
name = "Nail"
sku = 284758393
color = "gray"

This file has one key, products, holding a list of three tables: a hammer, an empty one, and a nail. If you know JSON, the same data looks like this:

{
  "products": [
    { "name": "Hammer", "sku": 738594937 },
    {},
    { "name": "Nail", "sku": 284758393, "color": "gray" }
  ]
}

The spec also notes you can write the same thing inline, as points = [ { x = 1, y = 2, z = 3 } ]. Once the tables grow past two or three keys, double brackets are easier to read.

The way to tell the two header types apart: the spec points out that you can tell headers from arrays because arrays are only ever values. A line that is nothing but [name] or [[name]] is a header.

Sub-tables attach to the latest item

This is the rule that trips people up. According to the spec, any reference to an array of tables points to the most recently defined table element of that array. So a sub-table header applies to whichever item came last:

[[fruits]]
name = "apple"

[fruits.physical]
color = "red"
shape = "round"

[[fruits.varieties]]
name = "red delicious"

[[fruits.varieties]]
name = "granny smith"

[[fruits]]
name = "banana"

[[fruits.varieties]]
name = "plantain"

Read it top to bottom. The first [[fruits]] starts the apple. Its physical table and two varieties belong to the apple, because the apple is the latest item in fruits. The second [[fruits]] starts the banana, and from then on [[fruits.varieties]] attaches to the banana. Nothing is indented, yet the structure is a tree: two fruits, each with its own list of varieties.

If the nesting is hard to see, indent the sub-tables. Indentation is ignored, so it costs nothing.

Rules that cause errors

TOML is strict about conflicts, and the spec says a parser must report an error for the cases below.

  • A table can't be defined twice. A second [fruit] header is invalid. So is writing apple = "red" under [fruit] and then adding [fruit.apple].
  • Out-of-order tables are allowed, but discouraged. Splitting [fruit.apple] and [fruit.orange] around an unrelated [animal] is valid. Keep related tables together anyway; it's easier on your eyes.
  • The array has to exist before its sub-tables. Writing [fruit.physical] before any [[fruit]] is invalid.
  • You can't mix the two forms for one name. Using [fruits.varieties] after [[fruits.varieties]], or [[fruits.physical]] after [fruits.physical], is an error.
  • A fixed array can't be extended. If you wrote fruits = [], a later [[fruits]] is an error, even though the array is empty.
  • Inline tables are closed. An inline table such as point = { x = 1, y = 2 } is fully self-contained. You can't add keys or sub-tables to it from outside the braces, and you can't use an inline table to add keys to a table defined elsewhere. Trailing commas aren't allowed inside the braces, and newlines are not allowed between them.

When a parser complains about a duplicate or a conflict, search the file for the header it names. Usually you'll find a second [[...]] you meant as [...], or the reverse.

Reading a real config file

Open a Cargo.toml or pyproject.toml and you will see both forms side by side: single-bracket tables for things like project metadata, and double-bracket items where a list of similar entries is needed. Apply the same two questions each time you see a header. Is it one bracket or two? And what is the latest [[...]] above it?

For the neighboring files you will edit in the same projects, see where Git settings live in config files. TOML supports comments with #, unlike strict JSON, which is covered in what to do when JSON has no comments.

How Carets fits in

Config files like these are plain text, and you often need to check one away from your desk: a build file on your phone, a Hugo config on an iPad. Carets is a native notes and code editor for iPhone, iPad, and Mac, so you can open a .toml file, read the headers with syntax highlighting for code and config files, and fix a stray bracket without starting a full IDE.

Your files stay plain text, organized into files, projects, and tags, so a config sits next to the notes about it and remains portable. If you have a TOML file that reads like a puzzle, try Carets on iPhone, iPad, and Mac.

Frequently Asked Questions

What is the difference between [table] and [[table]] in TOML?

Single brackets define one table. Double brackets define one element of an array of tables, and every repeat of the same header adds another element to that array.

Can I define the same TOML table twice?

No. A table cannot be defined more than once. Defining tables out of order is allowed, but the spec discourages it, so keep related tables together.

Can I add keys to an inline table later?

No. An inline table is fully self-contained, so keys and sub-tables cannot be added outside its braces. If you need to extend it, write it as a regular table with a header instead.