hexyl
A command-line hex viewer with colored output and a clean ASCII column — makes binary files readable at a glance.
hexyl is a command-line hex viewer written in Rust. It displays file contents
as a colored, formatted hex dump — distinguishing null bytes, printable ASCII,
whitespace, and non-ASCII bytes with distinct colors so you can understand the
structure of a binary file at a glance.
It is part of the same family of tools as bat, fd, and hyperfine — all by
the same author, all sharing a philosophy of clear output and sensible defaults.
Features
- Colored output — different byte categories are colored distinctly: null bytes, printable ASCII, whitespace, and high bytes each get their own color
- ASCII panel — a right-hand column shows the printable ASCII representation of each row
- Clean layout — offset, hex pairs, and ASCII columns are neatly aligned and easy to scan
- Range selection — view only a specific byte range within a file with
--skipand--length - Custom grouping — control how bytes are grouped per column with
--panelsand--group-size - Pipe-friendly — reads from stdin when no file is given
Installation
cargo install hexyl
Or via your system package manager:
# Debian/Ubuntu
apt install hexyl
# Fedora
dnf install hexyl
# macOS
brew install hexyl
# Arch Linux
pacman -S hexyl
# Nix
nix-env -iA nixpkgs.hexylUsage
# View a file
hexyl file.bin
# View the first 256 bytes
hexyl --length 256 file.bin
# Skip the first 512 bytes, then show 128 bytes
hexyl --skip 512 --length 128 file.bin
# Read from stdin (e.g. inspect a download)
curl -s https://example.com/file.bin | hexyl
# Inspect the first few bytes of any file
hexyl --length 16 /usr/bin/ls
# Show bytes in groups of 1 (no grouping)
hexyl --group-size 1 file.binExample output
Running hexyl --length 64 /usr/bin/ls on a Linux ELF binary produces output
like:
┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐
│00000000│ 7f 45 4c 46 02 01 01 00 ┊ 00 00 00 00 00 00 00 00 │•ELF•••⋄┊⋄⋄⋄⋄⋄⋄⋄⋄│
│00000010│ 03 00 3e 00 01 00 00 00 ┊ 00 10 40 00 00 00 00 00 │•⋄>⋄•⋄⋄⋄┊⋄•@⋄⋄⋄⋄⋄│
│00000020│ 40 00 00 00 00 00 00 00 ┊ f0 aa 02 00 00 00 00 00 │@⋄⋄⋄⋄⋄⋄⋄┊ו•⋄⋄⋄⋄⋄│
│00000030│ 00 00 00 00 40 00 38 00 ┊ 0d 00 40 00 1e 00 1d 00 │⋄⋄⋄⋄@⋄8⋄┊•⋄@⋄••••│
└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘
The ELF magic bytes (7f 45 4c 46) are immediately visible in the printable
ASCII column as •ELF.
Color categories
| Color | Byte type |
|---|---|
| Bright green | Printable ASCII characters (0x20–0x7e) |
| Dim green | Whitespace (space, tab, newline, etc.) |
| Orange | Null bytes (0x00) |
| Purple | Non-ASCII / high bytes (0x80–0xff) |
Tips
- Pair with
hexylandgrepto search for byte patterns in binary files - Use
--skipand--lengthto navigate large binary formats without loading the whole file - The ELF header, PNG magic bytes, ZIP local file headers, and other binary format signatures are instantly recognisable with colored output