carbon-now-cli
Generate beautiful images of source code
TLDR
SYNOPSIS
carbon-now [options] [file]
DESCRIPTION
carbon-now-cli generates beautiful images of source code using the Carbon service (carbon.now.sh). It automates the download of high-quality PNG or SVG code images with syntax highlighting, customizable themes, fonts, and backgrounds — all from the terminal.Input can be a file, piped stdin, or clipboard content. The file type is detected automatically for syntax highlighting. Use `--interactive` mode to be prompted for all visual settings, or save those settings as a named preset in `~/.carbon-now.json` for reuse with `--preset`.Each run's settings are automatically saved as `latest-preset`, so subsequent runs reuse the previous configuration without any extra flags. Named presets persist until manually deleted from `~/.carbon-now.json`.The `--settings` flag accepts a JSON string and has the highest override priority, after `--interactive`. Export size (`1x`, `2x`, `4x`), export type (`png`, `svg`), line numbers, drop shadow, padding, and custom per-token theme colors are all configurable through presets.
PARAMETERS
-i, --interactive
Launch interactive mode to customize theme, font, padding, and other settings before generating the image.-p, --preset name
Apply a saved preset from `~/.carbon-now.json`. Defaults to `latest-preset`, which automatically reuses the previous run's settings.--save-to path
Directory to save the image. Defaults to current working directory.--save-as name
Image filename without extension. Defaults to the source filename with a hash suffix.--from-clipboard
Read code from clipboard instead of a file or stdin.--to-clipboard
Copy the resulting image to clipboard instead of saving to disk.--open-in-browser
Open the Carbon URL in a browser for manual finishing instead of downloading the image.-s, --start line
Starting line number of input to use. Default: `1`.-e, --end line
Ending line number of input to use. Default: `1000`.--settings json
Override specific settings for this run as a JSON string (highest priority, overrides preset and interactive).--config file
Use a custom local config file instead of `~/.carbon-now.json` (read-only, changes are not persisted).--engine name
Rendering engine to use: `chromium` (default), `firefox`, or `webkit`.--skip-display
Do not display the image inline in the terminal after generation.--disable-headless
Run the Playwright browser in headful (visible) mode instead of headless.
CAVEATS
Requires internet connectivity to reach the Carbon rendering service. Custom theme colors set via the `custom` preset key are not applied when using `--open-in-browser` because they rely on `localStorage` inside the Playwright instance. Image generation depends on external service availability.
HISTORY
Carbon was created by Dawn Labs and launched in 2017 as a web application for creating beautiful code images. The carbon-now-cli was developed as a community project to provide command-line access to the service. It became popular among developers for quickly generating code images for documentation, tweets, and presentations without opening a browser.
SEE ALSO
silicon(1), pygmentize(1), highlight(1)
