hexyl - Colorful Command-Line Hex Viewer Cheatsheet
hexyl is a modern hex viewer for the terminal, written in Rust. It color-codes bytes by category — NULL, ASCII printable, ASCII whitespace, other ASCII, and non-ASCII — so structure jumps out at a glance, and it shows an aligned character panel alongside the hex. For quickly eyeballing file headers, magic bytes, and binary structure it is far more readable than xxd or hexdump, while staying scriptable with offset and length controls.
Installation
| Platform | Command |
|---|
| Cargo (all platforms) | cargo install hexyl |
| macOS (Homebrew) | brew install hexyl |
| Arch Linux | sudo pacman -S hexyl |
| Debian/Ubuntu | sudo apt install hexyl |
| Fedora | sudo dnf install hexyl |
| Windows (Scoop) | scoop install hexyl |
| Nix | nix-env -iA nixpkgs.hexyl |
Basic Usage
| Command | Description |
|---|
hexyl file.bin | Hex dump with color and character panel |
hexyl -n 64 file.bin | Show only the first 64 bytes |
| `head -c 256 file | hexyl` |
hexyl --help | Full option list |
hexyl --version | Version |
Range Control
| Option | Description |
|---|
-n, --length N | Read at most N bytes |
-c, --bytes N | Alias for length in bytes |
-s, --skip N | Skip (seek) N bytes before reading |
-r, --range A:B | Read the byte range from A to B |
--block-size N | Set the block size for -n/-s (e.g. 512) |
Offsets and counts accept units and bases: 0x1F, 512, 1KiB, 2MiB.
Display Options
| Option | Description |
|---|
| `—color always | auto |
| `—border ascii | unicode |
--panels N | Number of hex panels side by side (auto to fit width) |
--no-characters | Hide the right-hand character panel |
--no-position | Hide the offset column |
--group-size N | Bytes per group (1, 2, 4, 8) |
| `—base 2 | 8 |
-p, --plain | No colors, no borders, no position (xxd-like) |
Reading the Colors
| Color category | Meaning |
|---|
Dimmed 0 | NULL bytes (0x00) |
| Green | ASCII printable characters |
| Yellow/teal | ASCII whitespace |
| Other shade | Other ASCII control bytes |
| Bright | Non-ASCII (0x80–0xFF) |
This coloring makes magic numbers, padding, and text-versus-binary regions instantly visible.
Common Workflows
# Check a file's magic bytes / header
hexyl -n 16 mystery.file
# Inspect a specific structure at a known offset
hexyl -s 0x200 -n 0x40 firmware.bin
# Compare two files' headers quickly
hexyl -n 32 a.bin; echo '---'; hexyl -n 32 b.bin
# xxd-style plain output for diffing or scripts
hexyl --plain -n 64 file.bin
# Look at a slice of a stream
curl -s https://example.com/file | hexyl -n 128
| Feature | hexyl | xxd | hexdump |
|---|
| Color by byte category | Yes | No | No |
| Character panel | Yes | Yes | With format |
| Range/seek flags | Yes | Limited | Limited |
| Multi-panel layout | Yes | No | No |
| Plain/scriptable mode | Yes (-p) | Yes | Yes |
Resources