carbon-now
Create aesthetically pleasing code snippet images
TLDR
Create an image from a file using default settings
Create an image from a text in clipboard using default settings
Create an image from stdin using default settings and copy to the clipboard
Create images interactively for custom settings and optionally save a preset
Create images from a previously saved preset
Start at a specified line of text
End at a specific line of text
Open image in a browser instead of saving
SYNOPSIS
carbon-now [options] [file|stdin]
PARAMETERS
-c, --code <code>
Inline code snippet to render
-f, --file <file>
Path to file containing code
-l, --language <lang>
Programming language (auto-detected if omitted)
-t, --theme <theme>
Carbon theme name (e.g. 'one-dark')
--font <font>
Font family (e.g. 'Fira Code')
--bg.color <color>
Background color (e.g. '#000')
--line <range>
Line range to show (e.g. '1-10')
--first-line <num>
Starting line number
-p, --preset <preset>
Load saved preset
--config
Interactive configuration mode
--config-save
Save current config as preset
--save-to <path>
Save image to file
--copy
Copy image to clipboard
--upload
Upload to Imgur and print URL
--open
Open generated image
-h, --help
Show help
-v, --version
Show version
DESCRIPTION
carbon-now is a powerful command-line interface to the popular Carbon.now.sh web service, enabling users to generate stunning, customizable images of source code directly from the terminal. It supports rendering code from files, stdin, or inline strings with syntax highlighting, multiple themes, fonts, backgrounds, and line selections. Ideal for documentation, social media, blogs, or presentations, it produces shareable PNG images with professional styling.
Simply invoke with a file path to interactively configure and export, or use flags for automation. Features include saving locally, copying to clipboard, uploading to Imgur, or opening in the default viewer. Presets and config saving streamline repeated use. Requires Node.js and an internet connection to the Carbon API.
CAVEATS
Requires Node.js ≥14 and npm; internet access for Carbon API. No offline mode. Large code blocks may hit API limits.
INSTALLATION
npm i -g carbon-now-cli
Or npx carbon-now for one-off use.
EXAMPLES
carbon-now example.js (interactive)
cat foo.py | carbon-now --language python --theme dracula --save-to image.png
carbon-now --code 'console.log("hi");' --copy
HISTORY
Released in 2019 as carbon-now-cli on npm by Jake Lovett. Inspired by Carbon.now.sh (2018). Actively maintained on GitHub with 5k+ stars; supports latest Carbon features.


