T tomlkit·org
Inspect Formatter Validator Convert TOMLJSON JSONTOML TOMLYAML YAMLTOML INITOML TOMLINI .envTOML TOML.env TOMLTS Transform Sort keys Flatten Minify Compare Diff Merge

TOML to TypeScript Types

updated 24 May 2026

Emit a set of TypeScript interface declarations matching the shape of a TOML file. Use it to type-check a loaded config without writing the types by hand.

When to use it

Loading a TOML file in a TypeScript project usually means parsing to unknown and writing the types manually — tedious and error-prone. This tool walks a real TOML document and emits interfaces that match it exactly, so you can paste them into a .d.ts and get autocomplete + type checking for free.

Good for static configs: config.toml, app.toml, theme files, feature-flag schemas. Less useful for dynamic data where the shape isn't stable.

How to use it

  1. Paste your TOML on the left.
  2. Click Generate.
  3. Copy the interfaces into a .d.ts file in your project.

Type mapping

  • Stringsstring.
  • Integers and floatsnumber.
  • Booleansboolean.
  • Date / timeDate.
  • Tables → a nested interface, named after the key in PascalCase.
  • Arrays of tablesInterfaceName[], with the interface emitted from the first element.
  • Arrays of scalarstype[] when homogeneous; (typeA | typeB)[] otherwise.

FAQ

Does it handle optional keys?

Not yet. Every key in the sample becomes a required field. Edit the emitted output to mark fields optional (?) where appropriate.

What about deeply nested arrays?

Arrays of arrays are typed as type[][]. Mixed-shape arrays of tables fall back to unknown[]; pass a representative sample for cleanest output.

Can it generate a Zod or Valibot schema instead?

Not yet — but the structure is exactly the same shape, so it's a small future addition. Send me a request if you'd use it.