Skip to content

hexyl - Colorful Command-Line Hex Viewer Cheatsheet

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

PlatformCommand
Cargo (all platforms)cargo install hexyl
macOS (Homebrew)brew install hexyl
Arch Linuxsudo pacman -S hexyl
Debian/Ubuntusudo apt install hexyl
Fedorasudo dnf install hexyl
Windows (Scoop)scoop install hexyl
Nixnix-env -iA nixpkgs.hexyl

Basic Usage

CommandDescription
hexyl file.binHex dump with color and character panel
hexyl -n 64 file.binShow only the first 64 bytes
`head -c 256 filehexyl`
hexyl --helpFull option list
hexyl --versionVersion

Range Control

OptionDescription
-n, --length NRead at most N bytes
-c, --bytes NAlias for length in bytes
-s, --skip NSkip (seek) N bytes before reading
-r, --range A:BRead the byte range from A to B
--block-size NSet the block size for -n/-s (e.g. 512)

Offsets and counts accept units and bases: 0x1F, 512, 1KiB, 2MiB.

Display Options

OptionDescription
`—color alwaysauto
`—border asciiunicode
--panels NNumber of hex panels side by side (auto to fit width)
--no-charactersHide the right-hand character panel
--no-positionHide the offset column
--group-size NBytes per group (1, 2, 4, 8)
`—base 28
-p, --plainNo colors, no borders, no position (xxd-like)

Reading the Colors

Color categoryMeaning
Dimmed 0NULL bytes (0x00)
GreenASCII printable characters
Yellow/tealASCII whitespace
Other shadeOther ASCII control bytes
BrightNon-ASCII (0x800xFF)

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

hexyl vs Classic Tools

Featurehexylxxdhexdump
Color by byte categoryYesNoNo
Character panelYesYesWith format
Range/seek flagsYesLimitedLimited
Multi-panel layoutYesNoNo
Plain/scriptable modeYes (-p)YesYes

Resources