DEV Community

Cover image for Taking Pixel-Perfect Screenshots Every Time Using Chrome Devtools
Nick Scialli (he/him)
Nick Scialli (he/him)

Posted on

Taking Pixel-Perfect Screenshots Every Time Using Chrome Devtools

While most operating systems ship with built-in screenshotting tools, it's often desired to grab pixel-perfect screenshots. In this post, I'll show you how to do so using Chrome Devtools.

A Test Case -- The Sidebar Nav

To use Chrome Devtools to take screenshots, we'll want to be screenshotting something in the browser. Today's test case will be the sidebar nav (yes, that thing on the left of your home page). The following is a pixel-perfect example of what we'll be grabbing:

Dev sidebar nav screenshot

The Steps

The steps we need to take are as follows:

  1. Find the right node in Chrome Devtools "Elements" panel
  2. Open the Run Command prompt
  3. Select "capture node screenshot"

1. Finding the right node

To find the right node, I usually right-click on the element I'm looking for and click "inspect." This will take you to the "Elements" panel in devtools, at which point you can browse around to make sure you're selecting the right node. In this case, the div we're targeting has an id of sidebar-nav. When you have it correctly selected, your screen should look something like this:

Choosing the right node

2. Open the Run Command prompt

Once we have the right node selected, we need to open the Run Command prompt. There area couple ways to do this:

  1. Click on the vertical ellipsis (...) in the upper-right corner of devtools and click "Run command"
  2. (My preferred method) Just hitting ctrl + shift + p

You should now see something like this:

Run Command prompt

3. Select "Capture node screenshot"

Type "capture node screenshot" and hit enter once the right option is selected.

Capture node screenshot

You should see your screen take the screenshot and download the image!

That's It

You now know how to take pixel-perfect screenshots! Hopefully this helps you with all sorts of tasks, from working on design mocks to capturing bug reports.

Top comments (5)

lampewebdev profile image
Michael "lampe" Lazarski

In Firefox you can right-click the DOM Node.
Then you need to click on: "Screenshot Node"

matthijsewoud profile image

Safari has ‘console.screenshot([element])’.

darthbob88 profile image
Raymond Price

One caveat- this method only captures what is visible in the viewport. Taking a screenshot of this article, all I get is a lot of empty space and the last couple paragraphs.
linked to avoid table-breaking

kewbish profile image
Emilie Ma

Wow, never even explored that section. Super cool tip.

nas5w profile image
Nick Scialli (he/him)

Thanks! Devtools are so feature-rich, they never fail to surprise.