Online Zig Compiler
Compile and run Zig online with Zig 0.17. Write a program with a main function, press Run, and zig build-exe compiles it in Debug mode and starts it, with compiler errors shown by line if the build fails. Programs can read input from stdin as they run, and the standard library is ready to import.
How to run Zig code online
- This page opens with Zig selected, so you can start typing straight away.
- Write your code in the editor, or open files from your computer: single files, or a whole project as a .zip.
- Press Run, or Ctrl+Enter. The output appears in the panel beside the editor, and when the program asks for input you type it there and press Enter.
- Share a copy with a link, or save your files to your computer.
Zig 0.17 on Online IDE
- Your program is compiled with zig build-exe from Zig 0.17 in Debug mode, so overflows and out-of-bounds reads stop with a clear message.
- In Zig 0.17, files go through an Io instance: declare main(init: std.process.Init) and use init.io for stdout and stdin.
- Text written through a buffered writer appears when you call flush, so flush after a prompt and before reading input.
- The standard library is available, but packages and build.zig are not.
Example: a Zig program that reads input
const std = @import("std");
pub fn main(init: std.process.Init) !void {
var out_buffer: [1024]u8 = undefined;
var out = std.Io.File.Writer.init(.stdout(), init.io, &out_buffer);
const stdout = &out.interface;
var in_buffer: [1024]u8 = undefined;
var in = std.Io.File.Reader.initStreaming(.stdin(), init.io, &in_buffer);
try stdout.writeAll("Enter a whole number: ");
try stdout.flush();
const line = try in.interface.takeDelimiter('\n') orelse "";
const n = std.fmt.parseInt(u32, std.mem.trim(u8, line, " \r"), 10) catch 0;
if (n == 0) {
try stdout.writeAll("Please enter a whole number above zero.\n");
} else {
try stdout.print("Divisors of {d}:", .{n});
var d: u32 = 1;
while (d <= n) : (d += 1) {
if (n % d == 0) try stdout.print(" {d}", .{d});
}
try stdout.writeAll("\n");
}
try stdout.flush();
}
Features of this tool
- Simple and fastA clean, lightweight editor that opens instantly.
- Powered by AceThe Ace code editor, with syntax highlighting, autocompletion and bracket matching.
- Interactive programsType input into the terminal while your program runs.
- Several filesWork in tabs, open files or a .zip from your computer, and save the project back to disk.
- Made for learningHelpful for beginners to learn and practice programs.
- Light and dark themesPlus 39 editor themes, a choice of coding fonts, and Vim, Emacs or VS Code keys.
- Keep your outputCopy or download the program output in one click.
- Share by linkSave your code in the cloud and open it anywhere.
Frequently asked questions
Which Zig version does Online IDE use?
Zig 0.17, building for x86-64 Linux in Debug mode.
Why does code written for an older Zig not compile?
Zig's standard library changes between releases, and its I/O now goes through std.Io, so older code often needs updating, for example to get stdout from init.io.
How does a Zig program read input?
Make a std.Io.File.Reader for stdin and call takeDelimiter('\n') on its interface, as the example does. Type into the output panel while the program waits and press Enter.
Can I use build.zig or packages?
No. The file you run is compiled on its own with zig build-exe, and packages cannot be downloaded.
Contact us
For any feedback, queries or issues, please feel free to contact us or write to . We value your input and are committed to providing the best possible experience for our users.