0ximg is a Go-based command-line tool for rendering source code into shareable images through the 0ximg.sh API.
It supports reading code from:
- a file path
- standard input
- the system clipboard
The CLI also supports syntax highlighting, theme selection, line slicing, highlighted line ranges, layout customization, and automatic image download after rendering.
- Render code snippets to PNG images
- Read input from file,
stdin, or clipboard - Auto-detect language from file extension or shebang
- Render only a selected line range
- Highlight specific lines or ranges
- Customize theme, font, background, padding, shadows, and window chrome
- Print or copy a preview URL after rendering
- Go
1.25.7or newer - Network access to
https://0ximg.sh
go build -o 0ximg .go install 0ximg.sh/cli@latest0ximg [file] [flags]If no file is provided, 0ximg can read from stdin. You can also use --from-clipboard to render code directly from your clipboard.
0ximg main.go --theme Dracula --output main.go.pngcat main.go | 0ximg --language go --theme Dracula --output main.go.png0ximg --from-clipboard --language go --theme Nord --output snippet.png0ximg main.go --lines 10-20 --output snippet.png0ximg main.go --lines 10-20 --highlight-lines 12-14 --output snippet.png0ximg --list-themes| Flag | Description |
|---|---|
--from-clipboard |
Read code from the clipboard |
--list-themes |
Print available themes |
-o, --output |
Output image path |
-l, --language |
Language for syntax highlighting |
-t, --theme |
Theme used by the renderer |
-b, --background |
Background color |
-f, --font |
Font family |
--title |
Title metadata for rendering |
--window-title |
Custom window title |
--lines |
Render only a line range such as 10-20 |
--highlight-lines |
Highlight lines such as 1;5-12 |
--line-offset |
Starting line number |
--line-pad |
Padding between lines |
--no-line-number |
Hide line numbers |
--no-round-corner |
Disable rounded corners |
--no-window-controls |
Hide window controls |
--pad-horiz |
Horizontal padding |
--pad-vert |
Vertical padding |
--code-pad-right |
Right-side code padding |
--shadow-blur-radius |
Shadow blur radius |
--shadow-color |
Shadow color |
--shadow-offset-x |
Shadow X offset |
--shadow-offset-y |
Shadow Y offset |
--tab-width |
Tab width |
- When
--linesis used without--line-offset, the CLI automatically adjusts the displayed line numbers to match the original source file. - If
--outputis not explicitly set, the tool derives an output path automatically. - When rendering succeeds without an explicit
--output, the CLI prints a preview URL and attempts to copy it to the clipboard.
0ximg versionExample output:
version: dev
commit: none
date: unknown
Run tests with:
go test ./...If this tool is useful to you, support the project here:
https://buymeacoffee.com/levinhne