- Syntax highlighting — 400+ languages powered by syntect with a GitHub Dark theme
- Language detection — automatic detection via filename extension or Enry classifier (Go FFI)
- Markdown rendering — GitHub Flavoured Markdown compatible with syntax-highlighted code blocks
- URL shortening — paste a URL to get a short redirect link instantly
- Social previews — generates 1200×630 PNG preview images for social media embeds
- Paste expiration — set optional TTLs; expired pastes are cleaned up automatically
- LRU caching — rendered HTML and preview images are cached in memory
- Line linking — click a line number to link to it; shift-click to select a range
- Single binary — assets, fonts, and syntax definitions are all embedded
Prerequisites: Rust (edition 2024) and Go (for the Enry FFI).
git clone https://github.com/perosar/rustbin
cd rustbin
cargo build --releaseThe compiled binary will be at target/release/rustbin.
cp .env.example .env
# Edit .env as needed
./target/release/rustbinThe server starts on http://0.0.0.0:3000 by default.
Web UI — open the root URL in your browser and paste content into the textarea.
curl:
# Create a paste from a file
curl -F 'file=@main.rs' https://example.com
# Create a paste from stdin
echo 'fn main() {}' | curl -F 'file=@-' https://example.com
# Create a paste with an expiration
curl -F 'file=@script.py' -F 'expires_in=24h' https://example.com
# Shorten a URL
curl -F 'file=@-' https://example.com <<< 'https://example.com/very/long/url'The response contains the paste URL, e.g. https://example.com/aBcDeFgHiJ.
| Endpoint | Description |
|---|---|
GET /{id} |
Rendered paste with syntax highlighting |
GET /{id}.{ext} |
Rendered paste with a language hint (e.g. /{id}.go) |
GET /{id}/raw |
Raw plain-text content |
GET /{id}/preview.png |
1200×630 PNG preview image |
All configuration is done through environment variables (or a .env file).
| Variable | Default | Description |
|---|---|---|
DATABASE_URL |
sqlite://rustbin.db |
SQLite connection string |
HOST |
0.0.0.0 |
Bind address |
PORT |
3000 |
Bind port |
MAX_PASTE_SIZE |
2MB |
Maximum upload size (supports KB, MB, GB) |
CLASSIFIER_MAX_BYTES |
64KB |
Maximum content size for Enry-based language detection when no filename extension is present |
HIGHLIGHT_MAX_BYTES |
256KB |
Maximum content size for syntax-highlighted HTML rendering before falling back to plain text with line links |
RENDER_CACHE_CAPACITY |
128 |
Number of rendered HTML entries to cache |
CLEANUP_INTERVAL |
3600 |
Seconds between expired-paste cleanup runs |
DB_MIN_CONNECTIONS |
1 |
SQLite connection pool minimum |
DB_MAX_CONNECTIONS |
5 |
SQLite connection pool maximum |
RUST_LOG |
rustbin=info |
Log level filter (uses tracing-subscriber) |