Introduction
A .zig file holds source code in Zig, a
general-purpose programming language and toolchain. A .zon file holds ZON,
Zig Object Notation, a data format whose grammar is a subset of Zig’s. The best-known ZON
file is build.zig.zon, the manifest of a Zig package.
This page follows the Zig Language Reference for version 0.17.1, released on 2 November 2026. Zig has not reached version 1.0 and the language still changes between releases, so what is written here may not apply to other versions.
This reference is incomplete. Only this overview has been written so
far. There are no pages yet for the lexical structure, types, declarations, expressions,
control flow, functions, errors and optionals, casting, comptime, the builtin
functions, memory and illegal behaviour, concurrency, assembly, C interoperability,
testing, modules and the build system, ZON and build.zig.zon, the grammar,
the style guide, the standard library or the version history. Until then, use the
official reference linked above.
Structure
A Zig source file is UTF-8 text with LF line endings. Every file is implicitly a
struct, so it holds declarations and, optionally, fields, in any order.
Files find each other with @import.
const std = @import("std");
pub fn main() void {
std.debug.print("Hello, {s}!\n", .{"World"});
}
Links
Software
- Zig – the official compiler and toolchain, with
zig build,zig testandzig fmt(Windows, macOS, Linux) - ZLS – language server for Zig editors (Windows, macOS, Linux)
- Visual Studio Code – free code editor with a Zig extension (Windows, macOS, Linux)
Developers
Reference
- Zig Language Reference 0.17.1 – the official description of the language
- build.zig.zon documentation – the official list of the package manifest’s fields
- Zig Build System – the official guide to
build.zig - 0.17.0 release notes – what changed in the 0.17 series