Skip to content

Installing Zig

Before we write more Zig code, we need the Zig compiler.

Before we write more Zig code, we need the Zig compiler.

The compiler is the program that reads your .zig source files and turns them into programs your computer can run. Zig is distributed as a single toolchain. After installation, the main command you use is:

zig

The official latest Zig release is 0.16.0, released on April 14, 2026. The official site lists prebuilt downloads for Windows, macOS, Linux, FreeBSD, NetBSD, and OpenBSD.

In this book, when we say “Zig 1.16,” we are really targeting the Zig 0.16 release line, because Zig has not reached a 1.0 stable release yet.

The Best Way to Install Zig

The simplest beginner-friendly method is to download Zig directly from the official website.

Go to the Zig download page, choose the 0.16.0 release, then download the file for your operating system and CPU architecture. The official download page lists files such as zig-x86_64-linux-0.16.0.tar.xz, zig-aarch64-macos-0.16.0.tar.xz, and zig-x86_64-windows-0.16.0.zip.

You do not usually need to build Zig from source. For learning, use a prebuilt binary.

Check Your Operating System and CPU

You need to choose the right Zig package.

Most modern desktop computers are one of these:

SystemCommon choice
Windows on Intel or AMDx86_64-windows
macOS on Apple Siliconaarch64-macos
macOS on Intelx86_64-macos
Linux on Intel or AMDx86_64-linux
Linux on ARMaarch64-linux

Apple Silicon means M1, M2, M3, M4, or later Apple chips.

Intel or AMD desktop and laptop CPUs are usually x86_64.

ARM machines are usually aarch64.

If you choose the wrong package, the zig command may not run.

Installing on Windows

Download the Windows .zip file from the official Zig download page.

For a normal modern Windows computer, this is usually:

zig-x86_64-windows-0.16.0.zip

Extract the zip file somewhere simple, for example:

C:\zig

Inside that folder, you should see zig.exe.

Now open PowerShell and run:

C:\zig\zig.exe version

You should see:

0.16.0

That proves Zig works.

To make zig available everywhere, add C:\zig to your PATH.

On Windows, PATH is a list of folders where the terminal looks for commands. If C:\zig is in PATH, you can type:

zig version

instead of:

C:\zig\zig.exe version

After changing PATH, close and reopen PowerShell.

Installing on macOS

Download the correct macOS .tar.xz file.

For Apple Silicon Macs, use:

zig-aarch64-macos-0.16.0.tar.xz

For Intel Macs, use:

zig-x86_64-macos-0.16.0.tar.xz

Extract it. You can place the extracted folder somewhere like:

/opt/zig

or inside your home directory:

~/tools/zig

Then add the folder containing the zig executable to your shell path.

If you use zsh, which is the default shell on modern macOS, open ~/.zshrc and add a line like this:

export PATH="$HOME/tools/zig:$PATH"

Then reload your shell configuration:

source ~/.zshrc

Now check:

zig version

Expected output:

0.16.0

Installing on Linux

Download the correct Linux .tar.xz file.

For most Intel or AMD Linux machines, use:

zig-x86_64-linux-0.16.0.tar.xz

For ARM Linux machines, use:

zig-aarch64-linux-0.16.0.tar.xz

Extract the archive:

tar -xf zig-x86_64-linux-0.16.0.tar.xz

Move it somewhere stable:

mkdir -p "$HOME/tools"
mv zig-x86_64-linux-0.16.0 "$HOME/tools/zig"

Add it to your PATH.

If you use Bash, edit ~/.bashrc:

export PATH="$HOME/tools/zig:$PATH"

Then reload it:

source ~/.bashrc

Now test the install:

zig version

You should see:

0.16.0

Installing with a Package Manager

You may also install Zig with a package manager.

For example, on some systems you may use tools such as Homebrew, Chocolatey, Scoop, apt, pacman, Nix, or mise.

Package managers are convenient, but they may not always provide the exact version this book uses. The official download page is the safest choice when you want a specific Zig version.

For this book, prefer:

Zig 0.16.0 from the official Zig download page

That keeps your compiler version predictable.

Checking the Installation

After installation, always run:

zig version

For this book, the expected result is:

0.16.0

You can also run:

zig help

This prints the main commands supported by the Zig toolchain.

You will see commands for building, running, testing, formatting, translating C, and more.

Common commands include:

CommandMeaning
zig build-exeBuild an executable from a Zig file
zig runBuild and run a Zig file immediately
zig testRun tests in a Zig file
zig fmtFormat Zig source code
zig buildRun a project build script
zig ccUse Zig as a C compiler
zig c++Use Zig as a C++ compiler

At this stage, you only need three commands:

zig version
zig run
zig build-exe

Your First Installation Test

Create a file named:

hello.zig

Put this code inside it:

const std = @import("std");

pub fn main() void {
    std.debug.print("Hello from Zig!\n", .{});
}

Now run:

zig run hello.zig

You should see:

Hello from Zig!

The zig run command compiles the file and runs it in one step.

This is useful while learning because you can quickly test small programs.

Building an Executable

Now build the same file as a standalone program:

zig build-exe hello.zig

This creates an executable file.

On Linux and macOS, the output is usually:

hello

You can run it with:

./hello

On Windows, the output is usually:

hello.exe

You can run it with:

.\hello.exe

The difference is simple:

CommandWhat it does
zig run hello.zigCompile and run immediately
zig build-exe hello.zigCompile and leave an executable file

While learning, zig run is convenient. For real programs, you often use zig build or zig build-exe.

Common Installation Problems

If your terminal says:

zig: command not found

then Zig is not in your PATH.

This does not always mean Zig is missing. It usually means your terminal does not know where to find it.

Check where you extracted Zig. Then make sure that folder is listed in your PATH.

If Windows says:

'zig' is not recognized as an internal or external command

the cause is the same: Windows cannot find zig.exe.

Add the Zig folder to PATH, then open a new terminal.

If zig version prints a different version, you may have another Zig installation earlier in your PATH.

You can check which zig is being used.

On macOS or Linux:

which zig

On Windows PowerShell:

Get-Command zig

This shows the location of the Zig executable your terminal is using.

What You Installed

After installation, you have more than a compiler.

You have the Zig toolchain.

That includes:

Toolchain partPurpose
Zig compilerCompiles Zig source code
Build systemBuilds projects using build.zig
FormatterFormats code with zig fmt
Test runnerRuns tests with zig test
C compiler modeCompiles C code with zig cc
Cross compilerBuilds programs for other targets

This is one reason Zig is attractive. It gives you one command, zig, that handles many jobs normally split across several tools.

Once zig version works and zig run hello.zig prints text, your setup is ready.