Skip to main content
Version: Zig 0.11.0

Hello World

Create a file called main.zig, with the following contents:

const std = @import("std");

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

Use zig run main.zig to build and run it. In this example, Hello, World! will be written to stderr, and is assumed to never fail.

found 'invalid bytes'

Make sure your main.zig file is UTF-8 encoded as the Zig compiler does not currently support other encodings. To re-encode your file as UTF-8, run zig fmt main.zig and reopen the file in your editor.