What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
For a still image of the current desktop from a plain Node.js process, use screenshot-desktop: its Promise-based API returns an image buffer you can save or process. If the code runs inside Electron, use Electron’s desktopCapturer and media-stream APIs instead. The right choice depends on whether you need a local desktop image, an Electron screen or window stream, or capture as part of desktop automation—and whether the target machine has a permitted, interactive display session.
Choose the capture method that matches your runtime
“Node.js screenshot” can mean several different things. A script running in a logged-in desktop session can call a package that captures the machine’s screen and returns an image. An Electron application has its own screen and window source API, followed by browser media APIs. Automation libraries are a better fit when capture is one step in controlling or inspecting the desktop.
| Approach | Best fit | Important trade-off |
|---|---|---|
screenshot-desktop |
A local Node.js script that needs a still image and a simple Buffer-returning Promise API. | Its documentation lists ImageMagick for Linux; it says macOS and Windows need no dependencies. Verify current requirements and display IDs for your installed version. Package documentation |
Electron desktopCapturer |
An Electron app selecting a screen or window as a media source. | Source enumeration is followed by media capture, not a direct screenshot Buffer call. OS permissions and Linux PipeWire behavior affect results. Electron API documentation |
| RobotJS | Desktop automation that also needs screenshots, image matching, or pixel inspection. | Native build dependencies can complicate setup; its documentation describes capture of the main display. Check platform and runtime compatibility. RobotJS screen documentation |
node-screenshots |
An alternative native package when its current platform and architecture support fits deployment. | The project describes broad OS and Node support, but check the release’s exact matrix before adopting it. Package documentation |
This guide’s runnable example targets a plain Node.js process on a local machine with a usable desktop session. It does not assume a headless server can provide a visible screen.
Capture and save a desktop screenshot with screenshot-desktop
Install and check platform prerequisites
Install the package in your project:
npm install screenshot-desktop
According to the package documentation, Linux requires ImageMagick; macOS and Windows are documented as needing no dependencies. Confirm the current package instructions for your operating system, locked Node.js version, and deployment environment before relying on that statement.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Save the current screen as PNG
The package’s default output format is JPG. Pass format: 'png' when you need PNG. The returned value is a Node.js Buffer, so you can write it to disk, send it elsewhere, or pass it into an image-processing step.
const screenshot = require('screenshot-desktop');
const fs = require('node:fs/promises');
async function captureDesktop() {
try {
const image = await screenshot({ format: 'png' });
await fs.writeFile('desktop.png', image);
console.log('Saved desktop.png');
} catch (error) {
console.error('Screenshot capture failed:', error);
process.exitCode = 1;
}
}
captureDesktop();
Run it from the project directory with node your-file.js. On success, the script writes desktop.png in its current working directory. The try/catch is important: capture can fail if a display is unavailable, required platform tooling is missing, or the operating system denies access.
Select a display
To target a particular display, first list the displays and then pass the chosen display’s ID as the screen option, as shown in the package’s documented API pattern:
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
const screenshot = require('screenshot-desktop');
const fs = require('node:fs/promises');
async function captureSelectedDisplay() {
try {
const displays = await screenshot.listDisplays();
if (!displays.length) {
throw new Error('No displays were returned');
}
console.log('Available displays:', displays);
const display = displays[0];
const image = await screenshot({ screen: display.id, format: 'png' });
await fs.writeFile('selected-display.png', image);
} catch (error) {
console.error('Display capture failed:', error);
process.exitCode = 1;
}
}
captureSelectedDisplay();
Display identifiers and the returned display list are environment-specific. Inspect the actual output rather than assuming that the first display is the one you want. Handle an empty list, and keep capture errors visible in production logs.
Capture a screen or window in Electron
Electron’s desktopCapturer.getSources(options) enumerates screen and window sources. It does not return the same simple image buffer as screenshot-desktop; capture proceeds through a media stream. A renderer-side example can request a source and draw the stream’s video frame to a canvas:
const { desktopCapturer } = require('electron');
async function captureElectronSource() {
const sources = await desktopCapturer.getSources({
types: ['screen', 'window']
});
if (sources.length === 0) {
throw new Error('No screen or window sources are available');
}
const source = sources[0];
const stream = await navigator.mediaDevices.getUserMedia({
audio: false,
video: {
mandatory: {
chromeMediaSource: 'desktop',
chromeMediaSourceId: source.id
}
}
});
const video = document.createElement('video');
video.srcObject = stream;
await video.play();
const canvas = document.createElement('canvas');
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext('2d').drawImage(video, 0, 0);
const dataUrl = canvas.toDataURL('image/png');
stream.getTracks().forEach(track => track.stop());
return dataUrl;
}
This illustrates the source-to-stream-to-image shape; production Electron applications should follow the current Electron guidance for the version they ship, especially when choosing a source or exposing capture across renderer and main-process boundaries. On macOS 10.15 and later, Electron documents that capturing screen contents requires user consent. On Linux using PipeWire, Electron documents that only a single source is returned and PipeWire selects one capture for screens and windows. These are platform behaviors, not npm installation problems. See Electron’s current desktopCapturer documentation.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Account for operating system and deployment constraints
Linux
For screenshot-desktop, install the ImageMagick prerequisite listed in its package documentation and verify it is available to the user running Node.js. For Electron with PipeWire, do not assume source enumeration will expose a list of every screen and window: Electron documents single-source behavior in that environment.
macOS
Electron screen capture requires user consent on macOS 10.15 and later. A successful npm installation does not grant that permission. If capture is denied or unavailable, check the macOS privacy prompt and the app’s permission state.
Windows and package dependency claims
The screenshot-desktop documentation says macOS and Windows require no dependencies. Treat that as the package’s documented prerequisite information, not as a guarantee for every Node.js release, architecture, locked dependency tree, or managed desktop configuration.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Headless services, containers, and remote jobs
A desktop screenshot captures a desktop, not a webpage rendered in an abstract browser. A headless server, CI runner, or container may have no logged-in graphical session or usable display, and the cited package documentation does not promise otherwise. If capture must run there, establish and validate the display session and permissions in that exact environment. Do not infer headless compatibility from a successful local run.
Use an automation package when capture is part of automation
RobotJS is worth evaluating when the task includes desktop automation, image matching, or pixel inspection as well as screenshots. Its native build requirements can make installation more involved than a package with a compact capture API, and its documentation describes screen capture of the main display. Verify supported operating systems, Node.js versions, and architectures against the release you install and against your CI or deployment build environment. node-screenshots is another native-package option; its project claims broad platform support, but the current release’s exact OS and architecture matrix should determine whether it is appropriate.
Neither package should be selected on a platform-support claim alone. Test the capture path on the same operating system, display server, permissions model, Node.js version, and architecture used in deployment.
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Or skip the browser setup
If what you need is a screenshot of a website rather than the machine’s desktop, ScreenshotNeo is a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP, or PDF. It is not a replacement for capturing a local desktop or an Electron window.
Install the HTTP client if needed with npm install in your project (or use the built-in fetch available in current Node.js releases). Replace the example URL with the page 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}`);
For the complete request and response options, see the ScreenshotNeo documentation. Cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots, and 1,000 screenshots per month are free with no card; paid plans start at $5 for 3,000. Sign up for the free plan.
Troubleshoot common capture failures
| Symptom | Likely cause | What to check |
|---|---|---|
Module not found for screenshot-desktop |
The dependency is not installed in the project or the script runs from an unexpected project context. | Run npm install screenshot-desktop in the project and execute the script using that project’s Node.js environment. |
| Linux capture fails before producing a file | The package’s documented ImageMagick prerequisite may be missing or unavailable to the process. | Check the current package instructions and confirm the required executable is installed and reachable by the same user running Node. |
| No displays are listed, or capture fails on a server | The process may not have a usable interactive desktop session. | Run in a logged-in graphical session or configure and verify a display for the service environment; do not assume headless support. |
| Electron capture is denied on macOS | Screen-recording consent has not been granted. | On macOS 10.15 or later, check the app’s screen-capture permission and follow the OS consent flow. |
| Electron returns fewer sources than expected on Linux | PipeWire’s documented capture path returns one selected source. | Account for PipeWire source selection rather than expecting a full source list. |
| A native package fails to install or build | Required build tools, OS packages, architecture, or Node.js compatibility may not match. | Check the package’s release-specific platform matrix and build prerequisites in the exact CI or runtime environment. |
| Wrong monitor appears in the output | The code assumed a display ordering or reused an ID from another environment. | Log listDisplays(), inspect the IDs, and explicitly pass the intended ID with the screen option. |
Reliability, performance, and cost considerations
There are no comparable benchmark results established here, so do not choose a package based on assumed speed. Measure capture duration and failure frequency on the target machine if timing matters; local display state, permission prompts, native dependencies, and display-server behavior all affect operational reliability.
Recommended Free Tools
- Keep the environment stable: capture under the same user, display session, OS, architecture, and Node.js version used in production.
- Make failures observable: catch rejected Promises, log the error, and avoid treating a missing or empty output as a successful capture.
- Choose the output path for the job: save the Buffer directly for a still image, or use Electron media capture when the app needs to select a screen/window source.
- Account for native dependencies: Linux ImageMagick and native build toolchains have installation and maintenance costs even when the package itself is easy to call.
- Do not confuse image capture with web rendering: use local desktop tooling for a machine’s screen; use a web screenshot service when the input is a URL.
Frequently asked questions
Does screenshot-desktop save JPG or PNG by default?
The package documentation says JPG is the default. Set format: 'png' to request PNG.
Can a regular Node.js script capture a browser tab only?
The documented package approach captures a display, not a browser tab abstraction. For app-managed screen or window source capture, Electron provides desktopCapturer; a web-page URL screenshot is a separate use case.
Should I use RobotJS instead of screenshot-desktop?
Use RobotJS when screenshot capture belongs to a wider desktop automation or image-inspection workflow. For a straightforward local still capture, screenshot-desktop has the simpler documented Promise-and-Buffer shape.
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.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →

