Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
For a still image of the desktop from a regular Node.js process, use screenshot-desktop: call its Promise-based API, receive an image Buffer, and write that Buffer to a file. If the code runs inside Electron, use Electron’s desktopCapturer and media APIs instead. These approaches capture a local machine’s desktop; they are not interchangeable with taking a screenshot of a website in a remote browser.
The right choice depends on where Node.js runs, which operating system and display server it uses, and whether you need a still image, a screen/window stream, or capture as part of desktop automation.
Take a screenshot in a plain Node.js process
Install screenshot-desktop in the project, then call it with format: 'png'. The package documents a Promise API that resolves to an image Buffer. The following CommonJS example saves the result as desktop.png and reports capture failures:
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsconst screenshot = require('screenshot-desktop');
const fs = require('node:fs');
async function capture() {
try {
const image = await screenshot({ format: 'png' });
fs.writeFileSync('desktop.png', image);
console.log('Saved desktop.png');
} catch (error) {
console.error('Screenshot capture failed:', error);
process.exitCode = 1;
}
}
capture();
Run the script from a process with access to an interactive desktop session. The image Buffer can be written to disk, returned from a function, or passed to an image-processing library. The package documents JPG as its default format; specifying PNG avoids relying on that default.
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
Capture a particular display
When a machine has multiple displays, list them and pass a selected display’s ID as the screen option. Check for an empty list rather than assuming a monitor is available:
const screenshot = require('screenshot-desktop');
const fs = require('node:fs');
async function captureSelectedDisplay() {
try {
const displays = await screenshot.listDisplays();
if (displays.length === 0) {
throw new Error('No displays were reported');
}
const display = displays[0];
const image = await screenshot({ format: 'png', screen: display.id });
fs.writeFileSync('display.png', image);
console.log(`Saved screenshot from display ${display.id}`);
} catch (error) {
console.error('Display capture failed:', error);
process.exitCode = 1;
}
}
captureSelectedDisplay();
Use the display IDs returned by the package on the target machine; do not assume an ID will be stable across systems or runs. This API is for a local desktop screenshot, not a remote web page.
Choose an approach for your runtime
There is no single desktop-capture API that fits every Node.js deployment. Start with whether you have a regular Node process or an Electron application, then account for the kind of output, platform dependencies, and permissions.
Recommended Free Tools
| Approach | Best fit | Important trade-offs |
|---|---|---|
| screenshot-desktop | A still screenshot from a local, plain Node.js process | Returns a Buffer through a Promise API and supports display selection. Its documentation lists ImageMagick for Linux; it says macOS and Windows need no dependencies. Verify the package instructions for the exact release and environment. |
Electron desktopCapturer |
An Electron application that needs screen or window sources for a media stream | Source enumeration is followed by browser media capture, not a direct Buffer-returning call. macOS privacy consent and Linux PipeWire behavior can affect capture. |
| RobotJS | Capture combined with desktop automation, image matching, or pixel inspection | Native build tools and platform-specific dependencies can complicate installation. Its documentation describes capture of the main display. |
| node-screenshots | A native-package alternative when its current platform and architecture support match your deployment | The package README claims broad macOS, Windows, Linux, and Node-version support. Check the current release details for your OS and architecture before adopting it. |
Use screenshot-desktop when you want a compact local still-capture call and its prerequisites fit your target. Choose Electron’s API when the application is already Electron-based and needs a selectable screen or window as a stream. Consider RobotJS when capture is part of automation; assess node-screenshots only after confirming its current support matrix for the machines you deploy.
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
Capture a screen or window in Electron
Electron’s desktopCapturer.getSources(options) enumerates available screen and window sources. Capturing one of those sources uses browser media APIs, so the flow differs from calling a Node package and writing its returned Buffer.
- Call
desktopCapturer.getSourceswith the source types your application needs, such as screens or windows. - Let the user choose a returned source when the application should capture a particular screen or window.
- Use the selected source with Electron’s documented media-capture flow to obtain a stream, then process or record that stream according to the application’s needs.
Follow Electron’s current desktopCapturer documentation for the exact media constraints and application architecture. The source enumeration call alone is not a saved screenshot and does not return the same kind of image Buffer as screenshot-desktop.
Permissions and Linux source behavior
- macOS 10.15 and later: Electron documents that screen contents require user consent. Treat this as an operating-system privacy permission, not an npm installation problem.
- Linux with PipeWire: Electron documents a single-source behavior; PipeWire selects one capture for screens and windows. Do not assume an Electron app can enumerate and capture multiple choices as it might on another setup.
- Other environments: Available sources and capture permissions can depend on the OS, desktop session, and Electron version. Test the actual configuration your users run.
Check platform prerequisites before deploying
Linux
The screenshot-desktop package documentation lists ImageMagick as a Linux requirement. Install and verify the required tool in the same environment where the Node process runs. A package that works on a developer workstation can fail in a container or CI image that lacks that dependency.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchFor Electron, account for the PipeWire single-source behavior when the system uses PipeWire. Other native packages can have their own Linux library and build-tool requirements.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
macOS
The screenshot-desktop documentation says no dependencies are required on macOS. That does not remove Electron’s screen-recording consent requirement on macOS 10.15 and later. A successful package installation does not prove that the OS has granted an Electron app access to screen contents.
Windows
The screenshot-desktop documentation says no dependencies are required on Windows. Confirm behavior with the Node version, architecture, and display arrangement used in deployment rather than treating that statement as a guarantee for every locked runtime.
Native modules and version compatibility
RobotJS and other native packages may need compilers, platform build tools, or development libraries. Check the release documentation for supported Node versions, operating systems, and CPU architectures before pinning a dependency. Validate installation in the real CI or production image; native binary compatibility issues often appear there rather than in a developer’s interactive shell.
Free tools Windows power users keep installed
One-click scans. No signup required.
Headless servers and reliability
A desktop screenshot requires a usable display context. The package documentation describes capturing a local machine; it does not establish that a headless server or container has a visible desktop to capture. A process can be healthy and still have no interactive display session, no attached monitor source, or no permission to read screen contents.
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
- Run a minimal capture test on the same OS image, Node version, and architecture used in production.
- Check that a display session exists and that the process has access to it.
- For Electron on macOS, confirm that the app has the required user consent.
- For Linux, confirm required system packages and identify whether PipeWire affects Electron source selection.
- Handle rejected Promises, empty display lists, and missing output explicitly instead of assuming capture succeeded.
If the actual requirement is a website screenshot from a server, desktop-capture packages are usually the wrong abstraction: they capture the machine’s display rather than rendering a URL in a browser. Use a browser-capture workflow for that case.
Troubleshoot common failures
| Symptom | Likely cause | What to check or do |
|---|---|---|
| Capture Promise rejects on Linux | A documented system prerequisite such as ImageMagick is missing, or the process cannot access the desktop. | Install the prerequisite listed for the package release, then test from the same user and session as the application. |
| No displays are returned | The process may be running without an interactive display, or the environment does not expose one. | Check the login/display session and avoid assuming a headless container can produce a desktop image. |
| Electron lists fewer sources than expected on Linux | PipeWire can expose a single selected capture for screens and windows. | Account for PipeWire’s source-selection behavior in the app and test on the target desktop configuration. |
| Electron capture is blank or unavailable on macOS | Screen-content consent may not have been granted. | Check the OS privacy permission for the app and test the user-consent flow. |
| Native package installation fails | Build tools, development libraries, Node ABI, OS, or architecture may not match the installed package. | Compare the package’s current compatibility and build instructions to the exact runtime image; rebuild or choose a compatible release. |
| Wrong monitor captured | The package selected a default display or the chosen ID was not the intended one. | List displays at runtime and select from the IDs returned on that machine. |
Or skip the browser setup
If your goal is a screenshot of a website rather than the desktop attached to your Node process, ScreenshotNeo provides a website screenshot API and MCP server. A single GET request can return a PNG, JPEG, WebP, or PDF. For desktop capture, use the local approaches above; a website screenshot service does not capture your computer’s current screen.
Here is the Node.js request pattern, using the documented API endpoint and adapting the example URL to the site you want to capture:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
See the ScreenshotNeo API documentation for authentication, output settings, and response details. The API can remove cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. An MCP server gives AI agents tools for taking screenshots, inspecting page information, and capturing PDFs. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Sign up for ScreenshotNeo’s free plan.
Cost and performance considerations
For local desktop capture, the relevant costs are the runtime and infrastructure you already operate, plus any external system packages or native build setup the chosen library requires. The available package documentation does not provide comparative speed or reliability benchmarks, so choose by compatibility and the capture interface you need rather than assuming one option is faster.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
In production, avoid making capture success depend on an untested development machine. Pin and validate package versions, include system dependencies in deployment images, and test permissions and display availability as part of release checks. If the image is written to disk, make the destination and overwrite behavior explicit; if it is passed downstream, handle capture errors before processing the Buffer.
Frequently asked questions
Does screenshot-desktop take a screenshot of a website URL?
No. It captures a local display. Capturing a website URL requires browser rendering rather than desktop-screen capture.
Can a Node.js script capture a screenshot without a logged-in desktop?
Do not assume so. The cited package documentation does not promise headless-server capture; a usable display session and permissions may be necessary.
Should I choose PNG or JPG?
The package documents JPG as its default and shows PNG as an option. Choose the format your downstream workflow requires and specify it explicitly when predictable output matters.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

