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:Data Structures
ArrayList
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:Hash Maps
Hash map with array-based storage for cache-friendly iteration. Maintains insertion order.
Unmanaged variant of ArrayHashMap that does not store an allocator internally.
ArrayHashMap that automatically selects hash and equality functions based on key type.
HashMap that automatically selects hash and equality functions based on key type.
General-purpose hash map implementation.
Unmanaged variant of HashMap that does not store an allocator internally.
HashMap specialized for string keys.
ArrayHashMap specialized for string keys.
Bit Sets
Dynamically-sized bit set with allocator management.
Fixed-size bit set with compile-time known size.
Lists and Queues
A doubly-linked list implementation.
A singly-linked list implementation.
Double-ended queue allowing efficient insertion and removal at both ends.
Min-heap or max-heap based priority queue.
Priority queue that supports removal from both ends.
Other Data Structures
Structure-of-arrays list for improved cache locality.
Array indexed by enum values.
Map using enum values as keys.
Set of enum values.
Randomized binary search tree.
Core Modules
Memory Management
Memory utilities including comparison, copying, and manipulation functions.Location:
lib/std/mem.zigMemory allocators including GeneralPurposeAllocator, ArenaAllocator, and page_allocator.Location:
lib/std/heap.zigDebugging and Testing
Debugging utilities including assertions, stack traces, and panic handlers.Location:
lib/std/debug.zigTesting utilities for unit tests.Location:
lib/std/testing.zigLogging functionality with configurable levels and scopes.Location:
lib/std/log.zigFormatting and I/O
String formatting and parsing utilities.Location:
lib/std/fmt.zigFilesystem operations and directory handling.Location:
lib/std/fs.zigI/O operations and abstractions.Location:
lib/std/Io.zigSystem Interfaces
Operating system specific functionality (being phased out in favor of
posix).Location: lib/std/os.zigPOSIX system calls and interfaces.Location:
lib/std/posix.zigProcess-related functionality including argument parsing and environment variables.Location:
lib/std/process.zigThreading primitives and utilities.Location:
lib/std/Thread.zigText Processing
ASCII character classification and manipulation.Location:
lib/std/ascii.zigUnicode utilities and UTF encoding/decoding.Location:
lib/std/unicode.zigData Formats
JSON parsing and stringification.Location:
lib/std/json.zigZON (Zig Object Notation) parser.Location:
lib/std/zon.zigBase64 encoding and decoding.Location:
lib/std/base64.zigCompression and Archives
Compression algorithms (gzip, deflate, etc.).Location:
lib/std/compress.zigTAR archive format handling.Location:
lib/std/tar.zigZIP archive format handling.Location:
lib/std/zip.zigCryptography
Cryptographic primitives including hashing, encryption, and signatures.Location:
lib/std/crypto.zigMathematics
Mathematical functions and constants.Location:
lib/std/math.zigSIMD (Single Instruction Multiple Data) utilities.Location:
lib/std/simd.zigNetworking
HTTP client and server utilities.Location:
lib/std/http.zigBinary Formats
ELF (Executable and Linkable Format) parser.Location:
lib/std/elf.zigMach-O executable format parser.Location:
lib/std/macho.zigCOFF (Common Object File Format) parser.Location:
lib/std/coff.zigDWARF debug information format.Location:
lib/std/dwarf.zigPDB (Program Database) debug format.Location:
lib/std/pdb.zigWebAssembly format utilities.Location:
lib/std/wasm.zigUtilities
Hash functions (not cryptographic).Location:
lib/std/hash.zigSorting algorithms.Location:
lib/std/sort.zigCompile-time type introspection and metaprogramming utilities.Location:
lib/std/meta.zigAtomic operations.Location:
lib/std/atomic.zigExecute initialization code exactly once.Location:
lib/std/once.zigBuild System
The build system API for
build.zig files.See std.Build API Reference for complete documentation.Location: lib/std/Build.zigOther Types
Target architecture, OS, and ABI information.Location:
lib/std/Target.zigSemantic versioning parser and utilities.Location:
lib/std/SemanticVersion.zigURI parsing and manipulation.Location:
lib/std/Uri.zigRandom number generation.Location:
lib/std/Random.zigProgress reporting for long-running operations.Location:
lib/std/Progress.zigDynamic library loading.Location:
lib/std/dynamic_library.zigString-to-string hash map.Location:
lib/std/buf_map.zigSet of strings.Location:
lib/std/buf_set.zigCompile-time string map.Location:
lib/std/static_string_map.zigConfiguration
Stdlib-wide options that can be overridden by the root file.Set by defining
std_options in your root source file:See Also
- builtin namespace - Compiler-provided types and constants
- std.Build API - Build system for build.zig files