Render HTML to image from your terminal.
The official CLI for codetoimage.app. One npm install, one authentication, then any shell, build script, or CI job can render HTML/CSS into PNG, JPEG, or WebP — or get a hosted URL.
npm i -g @codetoimage/clinpx @codetoimage/cli render … without install.Quickstart
# 1. authenticate (paste a key from /dashboard/keys)
cti login
# 2. render an HTML file
cti render hello.html -o hello.png
# 3. inline HTML, custom size and format
cti render --html '<h1>Hello CLI</h1>' \
-f jpeg --quality 90 -w 1200 -h 630 -o og.jpg
# 4. separate CSS file
cti render card.html --css card.css -o card.png
# 5. get a hosted URL instead of bytes (24h CDN-served)
cti render og.html --url
# → https://img.codetoimage.app/r/9f3c…b1.pngWhat you can do with it
Build-time OG images
Generate static social previews at build time, commit alongside content. No runtime overhead.
CI screenshot tests
Render UI states from HTML fixtures in GitHub Actions for visual regression diffs.
Code → screenshot bots
Pipe gist/snippet content through the CLI, post the rendered PNG to Slack or Discord.
Dynamic email assets
Pre-render personalised header images during your campaign send loop.
PDF report covers
Generate cover pages from templated HTML, attach to nightly report exports.
Agent tool wiring
Wrap the CLI in n8n / Make / Zapier shell steps so any automation can render images.
CI / GitHub Actions
Add CODETOIMAGE_API_KEY as a repository secret, then call the CLI via npx. No global install needed in CI.
# .github/workflows/render-og.yml
name: render-og
on: { push: { branches: [main] } }
jobs:
render:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }
- run: |
npx @codetoimage/cli render og-template.html \
-o public/og.png -w 1200 -h 630 -f png
env:
CODETOIMAGE_API_KEY: ${{ secrets.CODETOIMAGE_API_KEY }}
- uses: actions/upload-artifact@v4
with: { name: og, path: public/og.png }Configuration
| Variable | Default | Purpose |
|---|---|---|
| CODETOIMAGE_API_KEY | — | API key. Overrides stored config. |
| CODETOIMAGE_API_URL | api.codetoimage.app | Override API base URL (dev / proxy). |
FAQ
How do I install the codetoimage CLI?▾
Run `npm i -g @codetoimage/cli` (requires Node 18+). You can also use it without install via `npx @codetoimage/cli render …`.
Where does the CLI store my API key?▾
When you run `cti login` the key is saved to ~/.config/codetoimage/config.json with chmod 600 (owner-only read). You can also pass it per-call via the --api-key flag, or set the CODETOIMAGE_API_KEY environment variable to skip persistent storage entirely.
Does the CLI work in CI / GitHub Actions?▾
Yes — set CODETOIMAGE_API_KEY as a secret, then invoke `npx @codetoimage/cli render` in your workflow. Exit codes are 0 on success and 1 on any error (auth, validation, plan limit, network) with details on stderr.
Can I get a hosted URL instead of a local file?▾
Yes — pass `--url`. The CLI prints a temporary public URL (24h TTL, CDN-served) to stdout. Useful for piping into other tools, posting to APIs that expect URLs (Instagram Graph, Slack unfurl, OG meta tags), or downstream automation.
Ready to render?
Sandbox is free — 50 renders/month, no credit card needed.