T tomlkit·org
Inspect Formatter Validator Lint Stats Keys Query Set value Convert TOMLJSON JSONTOML TOMLYAML YAMLTOML INITOML TOMLINI .envTOML TOML.env TOMLTS TOMLCSV CSVTOML TOMLXML TOML.properties .propertiesTOML Transform Sort keys Flatten Unflatten Redact Minify Generate Go struct Rust struct Python types JSON Schema Compare Diff Merge

TOML Set Value

updated 26 August 2026

Change one value and change nothing else. Give it a dotted path — package.version, tool.poetry.name, servers.1.ip — and a new value, and it rewrites just the characters after that key's equals sign. Comments stay, key order stays, spacing stays, quoting style stays. The diff is one line, which is the difference between a reviewable commit and an unreviewable one.

one line changes, nothing else

Why a text edit rather than a rewrite

The obvious way to change a TOML value is to parse the file into a data structure, set the field, and serialise it back out. Every other write-capable tool on this site works that way, and for converting between formats it is exactly right.

For editing a file you intend to keep, it is wrong. Parsing throws away everything that is not data: the comment explaining why a dependency is pinned, the blank line separating two sections, the decision to write 'literal' rather than "basic", the order the author chose. Serialising puts back a canonical form. The value you wanted to change is one line; the diff is the whole file, and nobody can review it.

So this tool never parses-and-re-emits. It reads the file once to confirm it is valid TOML — patching text you cannot parse is how you produce a broken Cargo.toml — then scans the lines tracking which table it is inside, finds the line that defines your key, and replaces the characters between the equals sign and the end of the value. Everything else is copied through byte for byte, down to the line endings: a CRLF file stays CRLF.

What it will not do

A value spread over several lines — a multi-line array, a triple-quoted string — cannot be patched by rewriting a single line, and half-rewriting one is how you get a file that no longer parses. When the target turns out to span lines the tool refuses and changes nothing, rather than doing something clever. Merge handles those, at the cost of reformatting.

It also will not invent structure it cannot place. A missing key is added under its table if that table exists, or in a new table appended at the end if it does not — but a key whose parent is an array of tables that has no matching index is an error, because there is no right answer to which block you meant.

Types, and when Auto guesses wrong

On Auto, a value that TOML would read as a number, a boolean, a date or a date-time is written bare, and anything else is quoted as a basic string. That is right almost always and wrong in one memorable case: a version like 2.0 is a valid float, so version = 2.0 is what you get, and Cargo will reject it. Set the type to String when the value only looks like a number.

Raw writes exactly what you typed with no quoting or checking, which is how you set an inline table or an array on one line: { version = "1.0", optional = true } or ["derive", "rc"]. It is also how you write a syntax error, so the status line's validation is worth reading afterwards.