Webidl for Zig
  • Zig 84.7%
  • TypeScript 14.5%
  • Nix 0.5%
  • JavaScript 0.3%
Find a file
Tristan Ross 068966e440
Some checks failed
CI / macos (Debug, aarch64-macos) (push) Has been cancelled
CI / macos (Debug, x86_64-macos) (push) Has been cancelled
CI / macos (ReleaseSmall, aarch64-macos) (push) Has been cancelled
CI / macos (ReleaseSmall, x86_64-macos) (push) Has been cancelled
CI / windows (Debug, aarch64-windows) (push) Has been cancelled
CI / windows (Debug, x86_64-windows) (push) Has been cancelled
CI / windows (ReleaseSmall, aarch64-windows) (push) Has been cancelled
CI / windows (ReleaseSmall, x86_64-windows) (push) Has been cancelled
CI / linux (Debug, aarch64-linux) (push) Has been cancelled
CI / linux (Debug, riscv64-linux) (push) Has been cancelled
CI / linux (Debug, x86_64-linux) (push) Has been cancelled
CI / linux (ReleaseSmall, aarch64-linux) (push) Has been cancelled
CI / linux (ReleaseSmall, riscv64-linux) (push) Has been cancelled
CI / linux (ReleaseSmall, x86_64-linux) (push) Has been cancelled
CI / node (push) Has been cancelled
fix: release handles that client wrappers make
2026-10-11 03:06:43 -07:00
.github feat: use zig 0.17 2026-10-10 03:19:56 -07:00
npm fix: release handles that client wrappers make 2026-10-11 03:06:43 -07:00
test fix: release handles that client wrappers make 2026-10-11 03:06:43 -07:00
tools refactor: zig 0.16 2026-07-01 21:38:03 -07:00
webidl fix: release handles that client wrappers make 2026-10-11 03:06:43 -07:00
.envrc feat: use zig 0.17 2026-10-10 03:19:56 -07:00
.gitattributes refactor: zig 0.16 2026-07-01 21:38:03 -07:00
.gitignore feat: use zig 0.17 2026-10-10 03:19:56 -07:00
build.zig feat: use zig 0.17 2026-10-10 03:19:56 -07:00
build.zig.zon feat: use zig 0.17 2026-10-10 03:19:56 -07:00
flake.lock chore(flake): update 2026-10-10 03:05:59 -07:00
flake.nix feat: use zig 0.17 2026-10-10 03:19:56 -07:00
LICENSE chore: use apache-2.0 2026-07-01 21:39:46 -07:00
README.md refactor: zig 0.16 2026-07-01 21:38:03 -07:00
treefmt.nix feat: use zig 0.17 2026-10-10 03:19:56 -07:00
webidl.zig refactor: zig 0.16 2026-07-01 21:38:03 -07:00

webidl.zig

WebIDL parser and Zig bindgen targeting Zig 0.16.

CLI

webidl2zig [--style model|host|client] [--emit json] [--mozilla] <input.webidl>... [-o output.zig]

  --style <s>   output style (default: model)
  --emit json   emit JSON IR instead of Zig (mutually exclusive with --style)
  --mozilla     accept Mozilla/Gecko WebIDL extensions (forward declarations,
                string/integer-valued extended attributes)
  -o <path>     write to file instead of stdout
  -h, --help    show this help

Multiple input files are read and resolved together in one scope, so a file may reference definitions declared in another:

zig build run -- --style host api.webidl -o api_host.zig
zig build run -- --mozilla --style client Node.webidl Element.webidl -o dom.zig

Build system helper

Add webidl.zig as a dependency, then in your build.zig:

const webidl = @import("webidl");

const api_mod = webidl.generateModule(b, b.dependency("webidl", .{}), .{
    .name = "api",
    .idl  = b.path("api.webidl"),
    .style = .model,
});
exe.root_module.addImport("api", api_mod);

Styles: .model (plain Zig structs), .host (vtable wrappers), .client (Wasm handle wrappers, auto-imports the runtime as core).