fq is a command-line tool and query language for inspecting and decoding binary data. It reuses jq’s expression syntax and adds decoders for many media, network, and filesystem formats.
Overview
fq treats binary files like structured documents: you run queries similar to jq to display decoded trees, hex views, or JSON representations. Basic invocations include displaying a file, probing formats, or evaluating expressions against inputs without extra boilerplate.
The tool bundles decoders for hundreds of named formats spanning audio, video, images, TLS, PCAP, archives, cryptocurrencies, and more, plus helpers for hex, base64, PEM, and URLs. It supports nested format decoding, slicing and concatenating byte ranges, bit-level reads, and an interactive REPL with completion.
Expressions extend jq with arbitrary-precision integers, raw backtick strings, binary value types, and additional functions for diffs, bit operations, and structured display options. Configuration covers color, truncation limits, decode forcing, and init files per operating system for custom functions.
Pre-built releases exist for macOS, Linux, and Windows, with package managers such as Homebrew, MacPorts, scoop, pacman, and emerge among the supported install paths. The manual is available as man fq and longer AsciiDoc documentation.
Key features
- jq-compatible query expressions
- Structural hex display modes
- Large catalog of format decoders
- Nested decoding and binary slicing
- Interactive REPL with auto-completion
- JSON, YAML, XML, and CSV transforms
- Configurable display and color options
- Bit-level decode and arithmetic helpers
Use cases
- Inspecting MP4 or PCAP structure
- Scripted extraction from binary logs
- Interactive exploration in the REPL
- Comparing decoded values between files
- Probing unknown files for format matches