TOML to serde.zig

TOML configs turn into Zig structs annotated for serde.zig. Use deny_unknown_fields from Options to reject typos in config keys.

Target

Strict configConservative u64; enums off; observed scalar values become Zig defaults — best for TOML/YAML configs.

title = "myapp"
port = 3000
debug = false

[database]
host = "localhost"
name = "main"
TOML 8 lines 87 B Drop files here to add samples
Config.zig
const serde = @import("serde");

pub const Config = struct {
    title: []const u8 = "myapp",
    port: u64 = 3000,
    debug: bool = false,
    database: Database,
};

pub const Database = struct {
    host: []const u8 = "localhost",
    name: []const u8 = "main",
};
loading zig fmt 2 structs · 6 fields 13 lines

Field decisions

Why each field got its type. Click a row to see it in the input; edit to override.

struct Config $ 4 fields
struct Database $.database 2 fields

What you get

  • Nested structs for every table, slices for arrays of tables.
  • Defaults from observed values with the Strict preset.
  • .deny_unknown_fields = true on every struct when you turn it on.

Questions

Can serde.zig reject unknown config keys?
Yes. Enable deny_unknown_fields in Options and parsing fails with error.UnknownField on any key the struct doesn't declare.