Pure Zig 0.16 · Zero deps · No libc

cat, but 4–26x faster and JSON-native.

ziggycat is a drop-in cat replacement in pure Zig. Byte-identical output on -n -b -s -E -T -TE -nbsET, plus a --json mode built for AI coding agents. One 502KB binary for Windows, macOS, Linux.

Terminal demo of ziggycat -n
FIG. 01 — ziggycat -n src/main.ziggrid variant
502KB
single binary, no runtime
4–26x
faster than GNU cat 9.x
0
dependencies, no libc
141
broken-pipe exit, SIGPIPE semantics

01 — Why

Why ziggycat exists

The most-piped command in every agent toolchain, optimized for agents that read files in loops.

✓ Byte-identical, provably

Line modes verified byte-for-byte against coreutils cat 9.x. Scripts cannot tell the difference.

✓ Agent-first JSON

One flag: path, size, numbered lines, escape-safe text, error records that don't kill the batch.

✓ Fast without tricks

No mmap, no threads, no unsafe. Raw syscalls, 1MB buffers, zero-copy line splitting. Flat memory at any input size.

✓ Exit codes pipelines respect

0 success, 1 file error (continues), 141 broken pipe, silent.

02 — Flags

Eight flags. Combined shorts work.

ziggycat -nbsET file.txt is valid. -n/-b are last-wins. A lone - reads stdin anywhere in the list.

ShortLongEffect
-n--numberNumber every output line, including blanks
-b--number-nonblankNumber non-empty lines only
-s--squeeze-blankCollapse runs of empty lines into one
-E--show-endsAppend $ to each line ending
-T--show-tabsRender tabs as ^I
—--jsonStructured output for agents
-h--helpUsage
-V--versionVersion

03 — JSON

Structured reads, not text dumps.

ziggycat --json example.txt

OUTPUT

{"files":[{"path":"example.txt","size":2048,"lines":[{"n":1,"text":"first line"}]}]}
  • stdin: path is "-", size is null.
  • Controls escape as \uXXXX; quotes and backslashes escape.
  • Unreadable files emit {"path":"...","error":"..."}, batch continues.
  • Empty files: "lines":[].

04 — Benchmarks

Faster than GNU cat 9.x.

94MB file (2M lines), ReleaseFast, sink /dev/null, median of 7 runs.

OperationziggycatcatSpeedup
Plain copy7ms28ms4x
-n number all7ms137ms20x
-b number non-blank5ms130ms26x
-s squeeze6ms112ms19x
-E show ends7ms109ms16x
-T show tabs6ms105ms18x
-TE tabs + ends6ms110ms18x
-nbsET all flags6ms130ms22x
--json6ms—no counterpart

05 — Install

Clone, build, alias.

Requires Zig 0.16.0. Binary lands at zig-out/bin/ziggycat (~502KB).

STEP 01

Clone

git clone https://github.com/AkashPriyadarshii/ziggycat.git
cd ziggycat
STEP 02

Build

Bench builds use ReleaseFast.

zig build -Doptimize=ReleaseSmall
STEP 03

Alias

alias cat=ziggycat
Windows note: in Git Bash, ziggycat means gzip's decompressor. ziggycat keeps its own name. Install at ~/.local/bin/ziggycat.exe.

06 — Trilogy

Read, find, orient.

File reading, search, and orientation as token-budgeted CLI tools.