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"});
}
Not described
Known, not yet covered
- Reference: this overview is the only page. The language has no reference pages for: lexical structure, types, declarations, expressions, control flow, functions, errors and optionals, casting, comptime, the builtin functions (
@import,@as,@intCastand the rest), memory and illegal behaviour, concurrency, assembly, C interoperability, testing, modules and the grammar. The official Zig Language Reference describes them. - Reference: ZON and
build.zig.zonare named on the overview but their syntax and the manifest fields are not described, and neither arebuild.zigand the build system, the standard library, the style guide andzig fmt, and the version history. Only Zig 0.17.1 is followed, and the language still changes between releases. - Viewer: a
.zonfile is coloured with the rules for Zig source. The.name = .my_pkgfield names and enum literals are plain, and nothing checks that the text is ZON. - Viewer: every
@builtin is coloured as a directive and every call as a function by name. Only the primitive types (u8,i32,usize,c_int,void) are coloured as types, so a struct, enum, union or error set you declare (const T = struct { … }) is plain. - Viewer: the file is not parsed or compiled, so there is no outline, no comptime evaluation and no list of problems, and only the first 1 MiB is read and coloured.
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