A pretty printer for zig
zig
Find a file
2026-01-27 17:27:12 +01:00
example improve options 2026-01-25 16:02:56 +01:00
.gitignore init 2026-01-20 13:56:24 +01:00
build.zig add build options to the example 2026-01-25 13:47:41 +01:00
build.zig.zon update build.zig.zon 2026-01-27 17:27:12 +01:00
LICENSE add README and MIT License 2026-01-27 14:08:53 +01:00
pretty.zig runtime is always const 2026-01-27 14:20:33 +01:00
README.md add README and MIT License 2026-01-27 14:08:53 +01:00

pretty

A compile-time pretty printer for Zig with colored terminal output.

Installation

Run:

zig fetch --save git+https://git.sr.ht/~altagos/pretty#main

Or manually add to build.zig.zon:

.dependencies = .{
    .pretty = .{
        .url = "git+https://git.sr.ht/~altagos/pretty#main",
        .hash = "<HASH>",
    },
}

In build.zig:

const pretty = b.dependency("pretty", .{ .target = target, .optimize = optimize });
exe.root_module.addImport("pretty", pretty.module("pretty"));

Usage

For a detailed example, see example/main

const pretty = @import("pretty").pretty;

std.debug.print("{f}\n", .{pretty(my_value)});

With Options

const prettyO = @import("pretty").prettyO;

std.debug.print("{f}\n", .{prettyO(my_value, .{
    .struct_inline = true,
    .array_inline = true,
})});

Global Defaults

pub const pretty_options = @import("pretty").Options{
    .skip_root_type_name = true,
    .theme = .{ .indent_width = 4 },
};

License

MIT License