snipshot
v1.0.3
Published
Generate PNG screenshots of code snippets with syntax highlighting, line numbers, and colored annotations from the CLI
Downloads
32
Maintainers
Readme
Features
- Syntax highlighting for 200+ languages via Shiki (VS Code-quality tokenization)
- Line numbers with proper gutter alignment
- Red/green highlights — full lines or precise column ranges
- Fold/collapse line ranges to hide boilerplate with
--fold - Word wrap with
--max-widthfor report-friendly output - Automatic language detection from 150+ file extensions, with graceful plaintext fallback for unknown types
- Dark theme (One Dark Pro)
- Offline — everything runs locally, no network needed
- Standalone binaries for Linux, Windows, and macOS (via Bun compile)
Install
# npm (requires Node.js >= 18)
npm install -g snipshot
# or run directly
npx snipshot <file> --lines <range>Usage
snipshot <file> --lines <start>-<end> [options]Options
| Option | Description |
|---|---|
| --lines <range> | Line range to capture, e.g. 42-56 (required) |
| --highlight-red <spec> | Highlight in red (repeatable) |
| --highlight-green <spec> | Highlight in green (repeatable) |
| --fold <range> | Collapse a line range into a single indicator row (repeatable) |
| --max-width <pixels> | Max image width — enables word wrap |
| --output <path> | Output file path (default: <name>_L<start>-<end>.png) |
| --root <path> | Project root for relative path display |
Highlight format
47 # entire line 47
47-50 # lines 47 through 50
47:12-38 # line 47, columns 12 to 38Examples
# Basic screenshot
snipshot src/App.java --lines 42-56
# With highlights
snipshot src/App.java --lines 42-56 --highlight-red 47 --highlight-green 50
# Column-precise highlight
snipshot src/App.java --lines 42-56 --highlight-red 47:12-38
# Word wrap for reports
snipshot src/App.java --lines 1-20 --max-width 700
# Fold boilerplate to focus on what matters
snipshot src/App.java --lines 1-80 --fold 5-30 --fold 60-70
# Custom output path
snipshot src/App.java --lines 42-56 --output screenshot.pngExamples
TypeScript with interface highlight and column annotation:
Word wrap with mixed highlights (--max-width 700):
Clean output without highlights:
Standalone binaries
Pre-built binaries include the Bun runtime — no Node.js installation needed on the target machine.
Download
Grab the archive for your platform from Releases, extract it, and run:
./snipshot src/App.java --lines 10-30Build from source
Requires Bun:
# All platforms (linux, win, mac-intel, mac-arm)
npm run build:standalone
# Specific platform
node scripts/build-standalone.mjs linux
node scripts/build-standalone.mjs win
node scripts/build-standalone.mjs mac-arm
# Multiple
node scripts/build-standalone.mjs linux,winOutput goes to standalone/snipshot-<platform>/. Each directory is self-contained.
Install system-wide (Linux/macOS):
sudo cp -r standalone/snipshot-linux-x64 /opt/snipshot
sudo ln -s /opt/snipshot/snipshot /usr/local/bin/snipshotHow it works
- Reads the full source file (not just the requested lines) to ensure accurate syntax highlighting
- Tokenizes with Shiki using the One Dark Pro theme
- Renders to a canvas with @napi-rs/canvas (Skia-based, no browser needed)
- Exports as PNG
The font used is JetBrains Mono (bundled).
Development
git clone https://github.com/n8tz/snipshot.git
cd snipshot
npm install
npm run build # compile TypeScript
npm test # run tests (29 tests)
npm run test:watch # watch modeLicense
MIT
