Generate beautiful code screenshots from your terminal. Like Carbon.now.sh, but as a CLI tool.
Stop opening websites just to screenshot your code. CodeSnap gives you pixel-perfect, syntax-highlighted code screenshots right from your terminal. Perfect for documentation, blog posts, Twitter, or showing off that clever one-liner.
- Syntax highlighting for 100+ languages via Shiki
- Multiple themes - Dark, Light, Monokai, Nord, Dracula, GitHub, Solarized
- macOS-style window controls - Optional window chrome for that polished look
- Custom backgrounds - Solid colors or gradients
- Line number control - Show/hide, or select specific line ranges
- Shadow effects - Add depth to your screenshots
- Piped input - Screenshot code from clipboard or command output
- Fast - Generates screenshots in seconds
npm install -g codesnapOr run locally:
git clone https://github.com/ranjan98/codesnap.git
cd codesnap
npm install
npm run build
npm link# Screenshot a file
codesnap capture myfile.js
# Custom output location
codesnap capture myfile.py --output screenshot.png# Use a specific theme
codesnap capture app.tsx --theme dracula
# See all available themes
codesnap themesAvailable themes:
dark(default)lightmonokainorddraculagithub-darkgithub-lightsolarized-darksolarized-light
# Add macOS-style window controls
codesnap capture server.go --window-controls --title "server.go"
# With custom background
codesnap capture api.rs --window-controls --bg "#282a36"# Hide line numbers
codesnap capture script.sh --no-line-numbers
# Capture specific lines (lines 10-25)
codesnap capture app.ts --start-line 10 --end-line 25# Custom background color
codesnap capture code.py --bg "#0d1117"
# Add shadow effect
codesnap capture main.cpp --shadow
# Custom padding
codesnap capture style.css --padding 60
# Combine all options
codesnap capture app.js \
--theme nord \
--window-controls \
--title "app.js" \
--bg "#2e3440" \
--shadow \
--padding 50 \
--output beautiful-code.png# Screenshot code from clipboard (macOS)
pbpaste | codesnap stdin --language javascript
# From a command
cat myfile.rb | codesnap stdin --language ruby --theme monokai
# From any output
git diff | codesnap stdin --language diffcodesnap capture example.jsCreates a dark-themed screenshot with syntax highlighting and line numbers.
codesnap capture train.py \
--theme github-dark \
--window-controls \
--title "train.py" \
--shadowCreates a GitHub Dark themed screenshot with window controls and shadow.
codesnap capture api.go \
--start-line 45 \
--end-line 67 \
--theme nord \
--output api-handler.pngScreenshots only lines 45-67 with Nord theme.
codesnap capture snippet.tsx \
--no-line-numbers \
--theme light \
--bg "linear-gradient(135deg, #667eea 0%, #764ba2 100%)" \
--padding 80 \
--shadowClean screenshot with gradient background, perfect for blog posts.
Auto-detects from file extension:
JavaScript, TypeScript, Python, Ruby, Go, Rust, Java, C, C++, C#, PHP, Swift, Kotlin, Bash, YAML, JSON, Markdown, HTML, CSS, SCSS, SQL, and many more.
Specify manually with --language flag if needed.
- Documentation - Clean code examples for README files
- Social Media - Share code snippets on Twitter/LinkedIn
- Blog Posts - Professional-looking code blocks
- Presentations - High-quality code slides
- Tutorials - Clear, readable code examples
- Code Reviews - Highlight specific sections
- High DPI displays - Screenshots are rendered at 2x resolution by default
- File size - PNG outputs are typically 50-200KB
- Custom fonts - Uses system monospace fonts (SF Mono on macOS)
- Gradients - Use CSS gradient syntax for
--bgoption
| Feature | CodeSnap | Carbon.now.sh | Polacode |
|---|---|---|---|
| CLI Interface | ✅ | ❌ | ❌ |
| Offline | ✅ | ❌ | ✅ |
| Batch Processing | ✅ | ❌ | ❌ |
| Piped Input | ✅ | ❌ | ❌ |
| Themes | 9+ | 20+ | 5+ |
| Window Controls | ✅ | ✅ | ✅ |
- More built-in themes
- Custom font selection
- Watermark support
- Batch processing multiple files
- SVG export option
- Configuration file support
- GIF generation for code diffs
Found a bug? Want a new theme?
git clone https://github.com/ranjan98/codesnap.git
cd codesnap
npm install
npm run dev capture test.jsSubmit issues or PRs on GitHub!
MIT License - see LICENSE for details
Made for developers who live in the terminal.
Give it a star if it saves you time! ⭐