How to Capture Website’s Screenshot Using Command Line

I know what you’re thinking: why bother with the command line for screenshots when I can just navigate to the website via a browser and take a screenshot using Mac’s keyboard shortcut or a screenshot tool?

Well, couple of reasons really.

Firstly, it’s genuinely enjoyable and useful to know. Secondly, using command lines allows for automation. You can duplicate commands, compile them into a script, and run it to batch capture screenshots of predetermined websites or URLs.

To take a screenshot on your Mac using the command line, here’s how to do it. Start by opening the Terminal app (duh!)

Next, you’ll need to adjust the following command to specify two key things:

  1. your screenshot’s saved location and its filename, and
  2. the URL of the website you want to capture.
/Applications/Google\\ Chrome \
  --headless \
  --screenshot=/path/to/screenshot/image.png \

Let’s walk through an example. If you want to capture a screenshot of, name it "apple.jpg", and save it to a folder named "screenshots", this is how your command would look:

/Applications/Google\\ Chrome \
  --headless \
  --screenshot=/screenshots/apple.png \

And this is what the screenshot will look like:

Standard screenshot

If you wish to customize the screenshot’s dimensions, you can do so by adding the following parameter:


For instance, to capture a screenshot of at a resolution of 450×800, your command should be formatted as follows:

/Applications/Google\\ Chrome \
  --headless \
  --window-size=450,800 \
  --screenshot=/screenshots/apple.png \

And here’s the resulting image:

Custom-size screenshot