Hello World
const std = @import("std");
pub fn main() void {
std.debug.print("Hello, World!\n", .{});
}Tap Run to execute
main.zig · output appears here
Press Run to execute
Output streams here as your program runs.
Zig is a general-purpose, statically typed systems programming language created by Andrew Kelley, with its first release in 2016. It aims to be a modern, robust alternative to C, emphasizing simplicity, explicit control over memory and control flow, and the absence of hidden allocations or hidden control structures. Zig has no preprocessor and no macros, using compile-time code execution instead.
Zig features powerful compile-time metaprogramming through comptime, manual memory management with explicit allocators, and a built-in cross-compilation toolchain that can also compile C and C++ code. There is no hidden control flow and errors are handled with error unions rather than exceptions. It is used for operating systems, embedded software, game engines, and high-performance tooling where predictability matters.
main.zig is the entry point. Add helper files from the explorer and import them into your project.
Use the Input panel to pipe standard input to your program when it needs data.
Run sends your code to a fresh hosted runtime and streams the result into the output panel.
Your draft stays in this browser, and Share creates a separate snapshot link.
main.zig imports helper.zig at compile time.
const std = @import("std");
const helper = @import("helper.zig");
pub fn main() void {
std.debug.print("{}\n", .{helper.answer()});
}
pub fn answer() u8 {
return 42;
}
const std = @import("std");
pub fn main() void {
std.debug.print("Hello, World!\n", .{});
}const std = @import("std");
pub fn main() !void {
var buf: [128]u8 = undefined;
var stdin_reader = std.fs.File.stdin().reader(&buf);
const line = try stdin_reader.interface.takeDelimiterExclusive('\n');
std.debug.print("Hello, {s}!\n", .{line});
}const std = @import("std");
pub fn main() void {
const nums = [_]i32{ 1, 2, 3, 4 };
for (nums) |n| {
std.debug.print("{d}\n", .{n * n});
}
}const std = @import("std");
fn add(a: i32, b: i32) i32 {
return a + b;
}
pub fn main() void {
std.debug.print("{d}\n", .{add(2, 3)});
}const std = @import("std");
fn divide(a: i32, b: i32) !i32 {
if (b == 0) return error.DivideByZero;
return @divTrunc(a, b);
}
pub fn main() void {
const result = divide(10, 0) catch |err| {
std.debug.print("Error: {s}\n", .{@errorName(err)});
return;
};
std.debug.print("{d}\n", .{result});
}const std = @import("std");
const Point = struct {
x: i32,
y: i32,
fn sum(self: Point) i32 {
return self.x + self.y;
}
};
pub fn main() void {
const p = Point{ .x = 3, .y = 4 };
std.debug.print("{d}\n", .{p.sum()});
}const std = @import("std");
pub fn main() void {
var i: u32 = 0;
var sum: u32 = 0;
while (i < 5) : (i += 1) {
sum += i;
}
std.debug.print("sum: {d}\n", .{sum});
const maybe: ?i32 = 42;
if (maybe) |value| {
std.debug.print("got {d}\n", .{value});
}
}const std = @import("std");
pub fn main() !void {
var debug_allocator = std.heap.DebugAllocator(.{}){};
defer _ = debug_allocator.deinit();
const allocator = debug_allocator.allocator();
var list = std.ArrayList(i32){};
defer list.deinit(allocator);
try list.append(allocator, 1);
try list.append(allocator, 2);
try list.append(allocator, 3);
for (list.items) |item| {
std.debug.print("{d}\n", .{item});
}
}const std = @import("std");
const Color = enum { red, green, blue };
fn name(c: Color) []const u8 {
return switch (c) {
.red => "red",
.green => "green",
.blue => "blue",
};
}
pub fn main() void {
std.debug.print("{s}\n", .{name(.green)});
}const std = @import("std");
const Value = union(enum) {
int: i32,
text: []const u8,
};
fn show(v: Value) void {
switch (v) {
.int => |n| std.debug.print("int: {d}\n", .{n}),
.text => |s| std.debug.print("text: {s}\n", .{s}),
}
}
pub fn main() void {
show(.{ .int = 42 });
show(.{ .text = "hello" });
}The editor uses Monaco, the engine behind VS Code, with language-aware editing tools and familiar keyboard controls.
Type or paste your code into the editor, then click Run (or press Ctrl/Cmd + Enter) to execute it.
Output streams into the console panel, including runtime errors, exit status, and execution time.
Nothing to install and no account to create — code runs in an isolated hosted runtime.
Language-aware autocomplete and IntelliSense suggestions where the editor has a matching language service
Syntax highlighting, with native compiler and runtime errors shown in the console
Bracket matching, auto-indentation, code folding, and a minimap
Multi-cursor editing plus find & replace (Ctrl/Cmd + F)
Full undo/redo history and copy to clipboard
Built on Monaco — the same editor that powers VS Code
Run on demand, or turn on Auto-run to execute on every change
Stop long-running or infinite programs at any time
A real console shows standard output, errors, exit status, and execution time
Pass standard input (stdin) to your program from the Input panel — one value per line
Switch between light and dark themes
Adjust font size and other editor settings
Toggle side-by-side or top/bottom layouts
Enter distraction-free fullscreen mode
Generate a shareable link to your exact code in one click — no login needed
Your work autosaves to your browser, so you can pick up where you left off
Copy the active file to your clipboard
Run code: Ctrl/Cmd + Enter
Find & replace: Ctrl/Cmd + F
Open the full shortcut list from the keyboard icon in the toolbar
Zig is one of 23 linked-project compilers. Run always starts main.zig; selecting a helper tab changes what you edit, not the entry file.
main.zig imports helper.zig at compile time.
Linked-project languages (23): Node.js, TypeScript, Deno, Python, C, Go, Dart, Swift, Rust, Ruby, PHP, Java, Kotlin, C++, C#, Nim, Crystal, Haxe, Zig, Scala, D, Bun, Objective-C.
Single-file scratchpads (46): Matplotlib, NumPy, pandas, Haskell, Clojure, Perl, Lua, Tcl, jq, Raku, Elixir, Bash, Zsh, Nushell, R, Assembly (NASM), Julia, Octave, Groovy, PowerShell, Visual Basic .NET, Odin, Pascal, Lisp, Erlang, CoffeeScript, COBOL, BASIC, V, Racket, OCaml, Prolog, AWK, Emacs Lisp, Emojicode, Forth, F#, Fortran, Assembly (NASM64), Solidity, Mojo, Ada, WASM (WAT), Gleam, Shell Script (sh), Scheme. Their extra project files are not submitted to the runtime.
Download project exports every Zig tab and a README in one ZIP archive.