- Home
- Code Formatting Tools
- Zig fmt
Zig fmt
What it is
Zig fmt is the source formatter included with the Zig toolchain. It parses Zig code using support from the standard library and formats it to a canonical style. The `--check` option lists files that do not conform on stdout and exits with an error if any are found, without changing their contents. The Zig build system can run the formatter across a codebase or a selected subset. Zig fmt can also convert invalid source encodings to valid ones, including by removing byte order marks and carriage returns. It formats Zig code and is available through Zig releases for Windows, macOS, and Linux; releases can also be installed from package managers. Editor integrations cited in release notes include Vim and VSCode. The formatter is included with Zig, whose listed plan is free. Release files are signed with minisign, and the download page recommends community mirrors for automated downloads to reduce downtime and bandwidth costs. The Zig Software Foundation is a 501(c)(3) nonprofit whose mission includes supporting Zig and its community, and it asks for recurring donations to fund development, maintenance, and support.
For and against
For
- Formats Zig code to a canonical style.
- Check mode reports nonconforming files without modifying them.
- Can run on a codebase or selected subset.
- Available for Windows, macOS, and Linux.
Against
- Formats Zig code only.
- Editor integrations cited are Vim and VSCode.
The verdict
Zig fmt provides canonical formatting as part of the free Zig toolchain, with a check mode suited to workflows that need to detect changes without rewriting files. Its scope is limited to Zig source code.
Who it suits
Zig fmt suits Zig developers who want consistent formatting or a check that flags files outside the canonical style. It can also be run on a whole codebase or a selected subset through the Zig build system.
Plans and prices
Zig fmt (included with Zig)
Zig source formatting · available as part of the Zig toolchain
Read 8 Oct 2026 · ziglang.org
On the record
- Automation
- The download page recommends community mirrors for automated downloads to avoid downtime and help reduce bandwidth costs.ziglang.org · read 8 Oct 2026
- Build system
- The Zig build system can run `zig fmt` on a codebase or a subset of it.ziglang.org · read 8 Oct 2026
- C and C++ projects
- The Zig home page says developers can use Zig as a zero-dependency C and C++ compiler with cross-compilation, and add Zig compilation units to C/C++ projects.ziglang.org · read 8 Oct 2026
- Check mode
- The `--check` flag lists nonconforming files on stdout and exits with an error if the list is nonempty, without modifying file contents.ziglang.org · read 8 Oct 2026
- Distribution
- Zig releases are available for Windows, macOS, and Linux, and the download page says release files are signed with minisign.ziglang.org · read 8 Oct 2026
- Editor integrations
- The release notes cite integrations for Vim and VSCode.ziglang.org · read 8 Oct 2026
- Encoding cleanup
- `zig fmt` can convert invalid source encodings to valid ones, including by stripping byte order marks and carriage returns.ziglang.org · read 8 Oct 2026
- How it works
- The formatter uses Zig code parsing support from the standard library.ziglang.org · read 8 Oct 2026
- How to run
- The Zig build system can run `zig fmt` on a codebase or a subset of it.ziglang.org · read 8 Oct 2026
- Linux support
- The download page lists Zig releases for Linux x86_64, aarch64, arm, riscv64, powerpc64le, x86, loongarch64, and s390x.ziglang.org · read 8 Oct 2026
- macOS support
- The download page lists Zig releases for macOS x86_64 and aarch64.ziglang.org · read 8 Oct 2026
- Maintainer organization
- The Zig Software Foundation is described as a 501(c)(3) nonprofit corporation founded in 2020 to support Zig development.ziglang.org · read 8 Oct 2026
- Offline documentation
- The language reference states that its HTML document depends on no external files and can be used offline.ziglang.org · read 8 Oct 2026
- Package managers
- The download page says Zig can also be installed from a package manager.ziglang.org · read 8 Oct 2026
- Part of Zig
- The download page provides Zig distributions that include the language reference and standard library documentation.ziglang.org · read 8 Oct 2026
- Purpose
- `zig fmt` is a tool for formatting Zig source code.ziglang.org · read 8 Oct 2026
- Release channel
- The download page lists a master build dated 2026-10-08 and links to its language reference and standard library documentation.ziglang.org · read 8 Oct 2026
- Signed files
- The download page says files are signed with minisign and provides a public key.ziglang.org · read 8 Oct 2026