Skip to main content
The std namespace is the root of Zig’s standard library and provides access to all standard library functionality.

Overview

The Zig standard library is imported with:
const std = @import("std");
This gives you access to all the standard library’s data structures, algorithms, and system interfaces.

Data Structures

ArrayList

ArrayList
fn(comptime T: type) type
A contiguous, growable list of items in memory. This is a wrapper around a slice of T values.The same allocator must be used throughout its entire lifetime. Initialize directly with empty or initCapacity, and deinitialize with deinit or toOwnedSlice.Example:
const std = @import("std");
const ArrayList = std.ArrayList;

var list = ArrayList(u8).init(allocator);
defer list.deinit();

try list.append(1);
try list.append(2);

Hash Maps

ArrayHashMap
type
Hash map with array-based storage for cache-friendly iteration. Maintains insertion order.
ArrayHashMapUnmanaged
type
Unmanaged variant of ArrayHashMap that does not store an allocator internally.
AutoArrayHashMap
type
ArrayHashMap that automatically selects hash and equality functions based on key type.
AutoHashMap
type
HashMap that automatically selects hash and equality functions based on key type.
HashMap
type
General-purpose hash map implementation.
HashMapUnmanaged
type
Unmanaged variant of HashMap that does not store an allocator internally.
StringHashMap
type
HashMap specialized for string keys.
StringArrayHashMap
type
ArrayHashMap specialized for string keys.

Bit Sets

DynamicBitSet
type
Dynamically-sized bit set with allocator management.
StaticBitSet
type
Fixed-size bit set with compile-time known size.

Lists and Queues

DoublyLinkedList
type
A doubly-linked list implementation.
SinglyLinkedList
type
A singly-linked list implementation.
Deque
type
Double-ended queue allowing efficient insertion and removal at both ends.
PriorityQueue
type
Min-heap or max-heap based priority queue.
PriorityDequeue
type
Priority queue that supports removal from both ends.

Other Data Structures

MultiArrayList
type
Structure-of-arrays list for improved cache locality.
EnumArray
type
Array indexed by enum values.
EnumMap
type
Map using enum values as keys.
EnumSet
type
Set of enum values.
Treap
type
Randomized binary search tree.

Core Modules

Memory Management

mem
module
Memory utilities including comparison, copying, and manipulation functions.Location: lib/std/mem.zig
heap
module
Memory allocators including GeneralPurposeAllocator, ArenaAllocator, and page_allocator.Location: lib/std/heap.zig

Debugging and Testing

debug
module
Debugging utilities including assertions, stack traces, and panic handlers.Location: lib/std/debug.zig
testing
module
Testing utilities for unit tests.Location: lib/std/testing.zig
log
module
Logging functionality with configurable levels and scopes.Location: lib/std/log.zig

Formatting and I/O

fmt
module
String formatting and parsing utilities.Location: lib/std/fmt.zig
fs
module
Filesystem operations and directory handling.Location: lib/std/fs.zig
Io
type
I/O operations and abstractions.Location: lib/std/Io.zig

System Interfaces

os
module
Operating system specific functionality (being phased out in favor of posix).Location: lib/std/os.zig
posix
module
POSIX system calls and interfaces.Location: lib/std/posix.zig
process
module
Process-related functionality including argument parsing and environment variables.Location: lib/std/process.zig
Thread
type
Threading primitives and utilities.Location: lib/std/Thread.zig

Text Processing

ascii
module
ASCII character classification and manipulation.Location: lib/std/ascii.zig
unicode
module
Unicode utilities and UTF encoding/decoding.Location: lib/std/unicode.zig

Data Formats

json
module
JSON parsing and stringification.Location: lib/std/json.zig
zon
module
ZON (Zig Object Notation) parser.Location: lib/std/zon.zig
base64
module
Base64 encoding and decoding.Location: lib/std/base64.zig

Compression and Archives

compress
module
Compression algorithms (gzip, deflate, etc.).Location: lib/std/compress.zig
tar
module
TAR archive format handling.Location: lib/std/tar.zig
zip
module
ZIP archive format handling.Location: lib/std/zip.zig

Cryptography

crypto
module
Cryptographic primitives including hashing, encryption, and signatures.Location: lib/std/crypto.zig

Mathematics

math
module
Mathematical functions and constants.Location: lib/std/math.zig
simd
module
SIMD (Single Instruction Multiple Data) utilities.Location: lib/std/simd.zig

Networking

http
module
HTTP client and server utilities.Location: lib/std/http.zig

Binary Formats

elf
module
ELF (Executable and Linkable Format) parser.Location: lib/std/elf.zig
macho
module
Mach-O executable format parser.Location: lib/std/macho.zig
coff
module
COFF (Common Object File Format) parser.Location: lib/std/coff.zig
dwarf
module
DWARF debug information format.Location: lib/std/dwarf.zig
pdb
module
PDB (Program Database) debug format.Location: lib/std/pdb.zig
wasm
module
WebAssembly format utilities.Location: lib/std/wasm.zig

Utilities

hash
module
Hash functions (not cryptographic).Location: lib/std/hash.zig
sort
module
Sorting algorithms.Location: lib/std/sort.zig
meta
module
Compile-time type introspection and metaprogramming utilities.Location: lib/std/meta.zig
atomic
module
Atomic operations.Location: lib/std/atomic.zig
once
fn
Execute initialization code exactly once.Location: lib/std/once.zig

Build System

Build
type
The build system API for build.zig files.See std.Build API Reference for complete documentation.Location: lib/std/Build.zig

Other Types

Target
type
Target architecture, OS, and ABI information.Location: lib/std/Target.zig
SemanticVersion
type
Semantic versioning parser and utilities.Location: lib/std/SemanticVersion.zig
Uri
type
URI parsing and manipulation.Location: lib/std/Uri.zig
Random
type
Random number generation.Location: lib/std/Random.zig
Progress
type
Progress reporting for long-running operations.Location: lib/std/Progress.zig
DynLib
type
Dynamic library loading.Location: lib/std/dynamic_library.zig
BufMap
type
String-to-string hash map.Location: lib/std/buf_map.zig
BufSet
type
Set of strings.Location: lib/std/buf_set.zig
StaticStringMap
type
Compile-time string map.Location: lib/std/static_string_map.zig

Configuration

options
Options
Stdlib-wide options that can be overridden by the root file.Set by defining std_options in your root source file:
pub const std_options = .{
    .log_level = .debug,
    .enable_segfault_handler = true,
};

See Also

Build docs developers (and LLMs) love