ripgrep vs ag (The Silver Searcher)
ag was the first widely-adopted grep replacement built for developers. ripgrep was built on top of ag's great ideas — and made everything faster, more portable, and better maintained.
Quick Verdict
ag was a great tool in its time and inspired ripgrep's design. But ag is largely unmaintained since 2018, requires external libraries (libpcre, zlib), and is measurably slower. If you use ag today, switching to ripgrep is a direct upgrade — nearly all flags are identical and you'll get better speed, Unicode support, and active maintenance.
Feature Comparison
| Feature | ripgrep | ag |
|---|---|---|
| Speed (large codebase) | ✅ Fastest | ⚠️ ~5× slower |
| Respects .gitignore | ✅ Yes (default) | ✅ Yes (default) |
| Skips hidden files | ✅ Yes (default) | ✅ Yes (default) |
| Skips binary files | ✅ Yes (default) | ✅ Yes (default) |
| Unicode support | ✅ Always on | ⚠️ Partial |
| PCRE2 regex | ✅ With -P | ✅ PCRE by default |
| File type filtering | ✅ -t flag | ✅ -G flag |
| Compressed file search | ✅ With -z | ❌ No |
| Single binary | ✅ Yes | ❌ Requires libpcre, zlib |
| JSON output | ✅ --json | ❌ No |
| Config file | ✅ .ripgreprc | ✅ .agignore |
| Windows support | ✅ Native | ⚠️ Limited |
| Actively maintained | ✅ Yes | ❌ Largely dormant since 2018 |
Speed
On the Linux kernel source tree, ripgrep completes in 0.082 s vs ag's 0.443 s — roughly 5× faster. On patterns with many matches the difference is more pronounced, since ripgrep's output pipeline is more efficient.
See the benchmarks page for detailed data.
When to use each
Use ripgrep when:
- ✓Starting fresh — no reason to pick ag in 2024
- ✓You need Windows support
- ✓You want compressed file search
- ✓You want JSON output for scripting
- ✓You need a self-contained binary
ag may still work if:
- →It's already installed and working for you
- →You use an editor plugin that only supports ag
Command Equivalents
ag and ripgrep share very similar flag names. Switching is mostly a matter of typing
rg instead of ag.
| Task | ripgrep | ag |
|---|---|---|
| Basic search | rg 'pattern' | ag 'pattern' |
| Case-insensitive | rg -i 'pattern' | ag -i 'pattern' |
| Word boundary | rg -w 'word' | ag -w 'word' |
| Invert match | rg -v 'pattern' | ag -v 'pattern' |
| Count matches | rg -c 'pattern' | ag -c 'pattern' |
| List matching files | rg -l 'pattern' | ag -l 'pattern' |
| Context (3 lines) | rg -C 3 'pattern' | ag -C 3 'pattern' |
| Only Python files | rg -t py 'pattern' | ag --python 'pattern' |
| Custom glob | rg -g '*.ts' 'pattern' | ag -G '\.ts$' 'pattern' |
| Search hidden files | rg -. 'pattern' | ag --hidden 'pattern' |
| Fixed string | rg -F 'literal' | ag -F 'literal' |
| Stats summary | rg --stats 'pattern' | ag --stats 'pattern' |
Migration
Switching from ag to ripgrep is one of the easiest migrations in the developer tooling world.
If you have alias ag=ag set, you can test with:
# Temporary alias to test ripgrep with ag muscle memory
alias ag='rg'
# Or add to your shell profile permanently
echo "alias ag='rg'" >> ~/.bashrc
# Editor configs: replace 'ag' binary path with 'rg' in settings