Guide

CLI

compress and decompress and identify and list from the terminal. Files or stdin in raw bytes or hex or base64

Install or run it

shell
npx @agntn/compressions identify mystery.bin
pnpm add -g @agntn/compressions

Five commands: compress, decompress, identify, list and mcp. Every one takes a file, or - for stdin.

Compress

shell
compressions compress deflate notes.txt --container gzip --level 9 > notes.txt.gz
compressions compress lzma notes.txt --container xz --check sha256 > notes.txt.xz
echo -n "hello world!" | compressions compress bzip2 - --to base64

Raw compressed bytes never go to a terminal. Redirect them, or pass --to base64 or --to hex.

FlagTakes
--containerdeflate raw, zlib, gzip. lzma alone, xz. lz4 frame, legacy
--leveldeflate 0 to 9, lzma 0 to 9, bzip2 1 to 9
--name, --mtimedeflate with --container gzip: the header fields
--checklzma with --container xz: none, crc32, crc64, sha256
--checksumlz4 frame: XXH32 of the content, on by default
--bitslzw: the widest code, 10 to 16
--from, --toraw, hex or base64

Decompress

shell
compressions decompress deflate notes.txt.gz --container gzip
echo 1f8b08000000000000ffcb48cdc9c95728cf2fca495104006dc2b4030c000000 \
  | compressions decompress deflate - --container gzip --from hex

What the stream says about itself goes to stderr, the bytes to stdout:

text
os: 255
members: 1
hello world!

--limit caps the output, --partial writes what came out before the damage. zstd and brotli decompress here too.

Identify

shell
compressions identify mystery.bin
text
100 deflate --container gzip  starts with its magic number; checksum matches; decodes to the last byte; decompresses to readable text  "hello world!"

One line per candidate: the score, the format, the flag that reads it, the reasons, a preview. Copy the middle and you have the decompress command. When nothing fits, it says so, and names the archive the bytes look like.

--peel takes off every layer, lists them on stderr and writes the innermost bytes to stdout:

shell
compressions identify nested.bin --peel > inner.txt

List

shell
compressions list
compressions list deflate
text
deflate (deflate)
LZ77 with Huffman codes: gzip files, zlib streams, PNG, HTTP and ZIP entries
standard  RFC 1951
writes    yes
container raw      raw deflate
container zlib     zlib, .zz .zlib, checksum Adler-32
container gzip     gzip, .gz .tgz, magic 1f8b08, checksum CRC-32
--container  raw deflate, a zlib stream or a gzip file (raw, zlib, gzip) (decompress too)
--level      0 stores, 1 is fastest, 9 is smallest (0 to 9)
--name       File name in the gzip header [gzip]
--mtime      Modification time in the gzip header, Unix seconds; 0 leaves it out (0 to 4294967295) [gzip]

compressions mcp starts the MCP server. Agents has the rest.