TOML to TypeScript Types
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
- Paste your TOML on the left.
- Click Generate.
- Copy the interfaces into a
.d.tsfile in your project.
Type mapping
- Strings →
string. - Integers and floats →
number. - Booleans →
boolean. - Date / time →
Date. - Tables → a nested
interface, named after the key in PascalCase. - Arrays of tables →
InterfaceName[], with the interface emitted from the first element. - Arrays of scalars →
type[]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.