Guide
How to take website screenshots from the command line

Taking website screenshots from the command line unlocks automation possibilities that GUI tools can't match. Whether you're monitoring competitors, generating thumbnails, or building visual regression tests, CLI tools let you script the entire process.
This guide covers the main approaches: headless browsers, dedicated CLI tools, and screenshot APIs.
Why capture screenshots from the terminal?
Command-line screenshot tools solve problems that browser extensions and manual captures can't:
- Automation: Schedule captures with cron, integrate into CI/CD pipelines
- Batch processing: Capture hundreds of URLs from a file
- Consistency: Same viewport, timing, and settings every time
- Headless operation: Run on servers without displays
- Scripting: Chain with other tools, parse output, trigger workflows
If you're capturing more than a few screenshots per week, CLI tools will save you hours.
Using AllScreenshots CLI
The fastest way to capture website screenshots from the terminal is with a dedicated tool. AllScreenshots CLI handles browser rendering in the cloud, so you don't need to manage headless Chrome locally.
Installation
# macOS/Linux with Homebrew
brew tap allscreenshots/allscreenshots
brew install allscreenshots
# Or with Cargo (Rust)
cargo install allscreenshotsBasic usage
Capture a screenshot and display it directly in your terminal:
allscreenshots https://github.comSave to a file instead:
allscreenshots https://github.com -o github.pngFull page screenshots
Capture the entire scrollable page, not just the viewport:
allscreenshots https://example.com --full-page -o fullpage.pngDevice emulation
Test responsive designs by simulating different devices:
# iPhone
allscreenshots https://example.com --device "iPhone 14" -o mobile.png
# Tablet
allscreenshots https://example.com --device "iPad Pro 11" -o tablet.png
# Desktop HD
allscreenshots https://example.com --device "Desktop HD" -o desktop.pngList all available device presets:
allscreenshots devicesBatch processing
Capture multiple URLs efficiently:
# From a file (one URL per line)
allscreenshots batch -f urls.txt -o ./screenshots/
# Multiple URLs inline
allscreenshots batch https://github.com https://gitlab.com -o ./screenshots/The batch command processes URLs concurrently, making it much faster than sequential captures.
Advanced options
| Option | Description |
|---|---|
--format png/jpeg/webp/pdf | Output format |
--quality 1-100 | Image quality (jpeg/webp) |
--delay 1000 | Wait before capture (ms) |
--dark-mode | Enable dark mode |
--block-ads | Block advertisements |
--block-cookies | Hide cookie banners |
--wait-for ".selector" | Wait for element to appear |
Example combining options:
allscreenshots https://example.com \
--full-page \
--dark-mode \
--block-cookies \
--format jpeg \
--quality 90 \
-o screenshot.jpgUsing Puppeteer from the command line
If you prefer running your own headless browser, Puppeteer can be wrapped in a simple Node.js script:
#!/usr/bin/env node
// screenshot.js
const puppeteer = require('puppeteer');
const url = process.argv[2];
const output = process.argv[3] || 'screenshot.png';
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({ width: 1920, height: 1080 });
await page.goto(url, { waitUntil: 'networkidle0' });
await page.screenshot({ path: output, fullPage: true });
await browser.close();
console.log(`Saved: ${output}`);
})();Run it:
node screenshot.js https://example.com output.pngMaking it more flexible
A more complete script with options:
#!/usr/bin/env node
const puppeteer = require('puppeteer');
const { program } = require('commander');
program
.argument('<url>')
.option('-o, --output <file>', 'output file', 'screenshot.png')
.option('-w, --width <px>', 'viewport width', '1920')
.option('-h, --height <px>', 'viewport height', '1080')
.option('-f, --full-page', 'capture full page')
.parse();
const url = program.args[0];
const opts = program.opts();
(async () => {
const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
const page = await browser.newPage();
await page.setViewport({
width: parseInt(opts.width),
height: parseInt(opts.height)
});
await page.goto(url, { waitUntil: 'networkidle0' });
await page.screenshot({
path: opts.output,
fullPage: opts.fullPage || false
});
await browser.close();
console.log(`Saved: ${opts.output}`);
})();Using Playwright CLI
Playwright includes a built-in screenshot command:
# Install Playwright
npm install -g playwright
# Capture screenshot
npx playwright screenshot https://example.com screenshot.png
# Full page
npx playwright screenshot --full-page https://example.com fullpage.png
# Specific viewport
npx playwright screenshot --viewport-size=1280,720 https://example.com screenshot.pngPlaywright's CLI is convenient for quick captures but lacks advanced features like ad blocking or cookie banner removal.
Using Chrome headless directly
Chrome itself can capture screenshots without additional tools:
# macOS
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--headless \
--disable-gpu \
--screenshot=screenshot.png \
--window-size=1920,1080 \
https://example.com
# Linux
google-chrome \
--headless \
--disable-gpu \
--screenshot=screenshot.png \
--window-size=1920,1080 \
https://example.comThis approach works but has limitations:
- No full-page capture
- No waiting for dynamic content
- Basic viewport control only
- No device emulation
For anything beyond simple captures, use Puppeteer or a dedicated tool.
Using Firefox headless
Firefox also supports headless screenshots:
firefox \
--headless \
--screenshot screenshot.png \
--window-size=1920,1080 \
https://example.comSame limitations as Chrome's built-in approach apply.
Using curl with screenshot APIs
If you want to avoid local browser dependencies entirely, screenshot APIs work via HTTP:
# Using AllScreenshots API directly
curl --fail-with-body -X POST "https://api.allscreenshots.com/v1/screenshots" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com","fullPage":true,"responseType":"binary"}' \
-o screenshot.pngThis approach works from any environment that has curl, including minimal Docker containers and serverless functions.
Comparison of approaches
| Approach | Setup | Speed | Features | Best For |
|---|---|---|---|---|
| AllScreenshots CLI | Minimal | Fast | Full | Daily use, automation |
| Puppeteer script | Moderate | Slow | Customizable | Custom workflows |
| Playwright CLI | Easy | Slow | Basic | Quick one-off captures |
| Chrome headless | None | Slow | Limited | Simple captures |
| curl + API | None | Fast | Full | Serverless, containers |
Automating with cron
Schedule regular captures with cron:
# Edit crontab
crontab -e
# Capture every hour
0 * * * * allscreenshots https://example.com -o ~/screenshots/$(date +\%Y\%m\%d-\%H\%M).png --no-display
# Capture daily at 9am
0 9 * * * allscreenshots https://competitor.com -o ~/monitoring/competitor-$(date +\%Y\%m\%d).png --no-displayIntegrating with shell scripts
Combine screenshot captures with other tools:
#!/bin/bash
# monitor-sites.sh
SITES=(
"https://github.com"
"https://gitlab.com"
"https://bitbucket.org"
)
OUTPUT_DIR=~/screenshots/$(date +%Y-%m-%d)
mkdir -p "$OUTPUT_DIR"
for site in "${SITES[@]}"; do
filename=$(echo "$site" | sed 's|https://||' | sed 's|/|_|g')
allscreenshots "$site" -o "$OUTPUT_DIR/${filename}.png" --no-display
echo "Captured: $site"
done
echo "All screenshots saved to $OUTPUT_DIR"Conclusion
Command-line screenshot tools transform what would be tedious manual work into automated workflows. For most users, a dedicated CLI tool like AllScreenshots offers the best balance of simplicity and features. You get cloud rendering, device emulation, and batch processing without managing headless browsers.
If you need complete control over the browser, Puppeteer scripts let you customize every aspect of the capture. For quick one-off screenshots, Playwright's CLI or Chrome's built-in headless mode work fine.
Start with simple captures, then add automation as your needs grow. A few lines of bash can replace hours of manual screenshot work.
Find out how easy it is to capture and share pixel-perfect screenshots at scale using Allscreenshots. Sign up for a free account and start integrating your first screenshot API call today.


