A CLI tool to turn your code into beautiful, shareable images—right from the command line.
Perfect for docs, tweets, slides, bug reports, and more.
Note
Try codeshot with nvim! codeshot.nvim
- Syntax highlighting for 100+ languages (Chroma-powered)
- Customizable themes (Dracula, Gruvbox, OneDark, and more)
- Modern fonts (bundled FiraCode or any TTF)
- Gorgeous output: rounded corners, shadow, macOS-style bar, true color
- Easy clipboard copy (if supported)
- Direct integration with editors and scripts (supports piping, files, or raw text)
- Lightning fast—written in Go
Requires Go 1.21+ (for
go installmethod).
Prebuilt binaries coming soon!
go install github.com/flothjl/codeshot@latestMake sure $GOBIN (usually ~/go/bin) is in your $PATH.
codeshot --file main.goThis will save a codeshot.png in your current directory, highlighting the code.
Input from STDIN:
cat main.go | codeshot --lang go --theme dracula --out main.pngSelect a theme:
codeshot --file app.py --theme gruvboxSet output file or copy to clipboard:
codeshot --file main.go --out /tmp/myshot.png
codeshot --file main.go # (default: screenshot.png)(Clipboard copy coming soon! On macOS/Linux)
Change font:
codeshot --file foo.rs --font "/path/to/JetBrainsMono-Regular.ttf"| Flag | Description | Example |
|---|---|---|
--file |
Path to input code file | --file main.go |
--text |
Raw code as an argument | --text "print(42)" |
--lang |
Filetype/language (e.g., go, python) |
--lang go |
--theme |
Chroma style (default: dracula) |
--theme gruvbox |
--font |
Path to TTF font | --font ./fonts/FiraCode-Regular.ttf |
--out |
Output file path | --out /tmp/code.png |
- Dracula
- Gruvbox
- OneDark
- Nord
- Solarized Dark/Light
- (and many more! See Chroma Styles)
Anything Chroma supports—Go, Python, JS, Rust, HTML, Bash, C, Lua, and over 100 more.
-
With Neovim (codeshot.nvim):
Visually select code, run:Codeshotor<leader>cs, screenshot is auto-created! -
With VSCode:
Add a custom task or keybinding to callcodeshoton the current file. -
With Shell Scripts:
for f in *.go; do codeshot --file "$f" --out "${f%.go}.png"; done
- Use high-res fonts for better screenshots.
- Combine with
imgcatin iTerm2 to display images inline! - Works great in CI/CD for visual code diffs.
git clone https://github.com/flothjl/codeshot.git
cd codeshot/cmd/codeshot
go build -o codeshotPull requests welcome!
Open an issue to suggest features or report bugs.
Joshua Floth
github.com/flothjl
Star this repo if you find it useful!
