Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteCall Playwright’s screenshot method without a path, keep the returned bytes in memory, and pass them to your language’s Base64 encoder. In Node.js, the complete operation is const base64 = (await page.screenshot()).toString('base64');. The same pipeline works in Python, Java and .NET with their native byte-array encoders. This avoids creating an intermediate image file and lets you send the result to an API, database, message, or HTML response.
The core pattern: screenshot bytes, then Base64
Playwright returns image data when you omit the path option. JavaScript receives a Buffer; Python receives bytes; Java receives a byte[]; and .NET receives a byte[]. Encode that value immediately, before any text conversion.
The examples below follow the current official Playwright guides for each language: JavaScript, Python, Java and .NET. API details can vary with your installed Playwright version, so use the documentation matching that version.
Node.js (JavaScript)
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
await page.goto('https://example.com', { waitUntil: 'networkidle' });
const screenshotBuffer = await page.screenshot();
const base64 = screenshotBuffer.toString('base64');
console.log(base64);
await browser.close();
})();
page.screenshot() returns a Promise<Buffer>. Calling toString('base64') on that buffer produces raw Base64 text, not a data URL. To save a file instead, pass { path: 'screenshot.png' }; a path is optional for the in-memory workflow.
#1 Best Overall
- Model: Dell OptiPlex 7050 Small Form Factor (SFF)
- Processor: Intel Core i7-7700 3.60 GHz
- Memory: 32GB DDR4 Ram
- Storage: 1TB Solid State Drive (SSD) Fast Boot + Storage
- Operating System: Windows 11 Pro (64-bit)
Python
import asyncio
import base64
from playwright.async_api import async_playwright
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch()
page = await browser.new_page(viewport={"width": 1440, "height": 900})
await page.goto("https://example.com", wait_until="networkidle")
screenshot_bytes = await page.screenshot()
base64_string = base64.b64encode(screenshot_bytes).decode("ascii")
print(base64_string)
await browser.close()
asyncio.run(main())
The synchronous Python API uses the same conversion: base64.b64encode(page.screenshot()).decode("ascii"). Keeping the bytes as bytes until encoding prevents accidental character decoding of binary image data.
Java
import com.microsoft.playwright.*;
import java.util.Base64;
public class ScreenshotBase64 {
public static void main(String[] args) {
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().launch();
Page page = browser.newPage();
page.navigate("https://example.com");
byte[] buffer = page.screenshot();
String base64 = Base64.getEncoder().encodeToString(buffer);
System.out.println(base64);
browser.close();
}
}
}
Java’s page.screenshot() returns a byte array. If you need full-page or element capture, use the options shown below before encoding the returned array.
.NET (C#)
using Microsoft.Playwright;
using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();
await page.GotoAsync("https://example.com", new() { WaitUntil = WaitUntilState.NetworkIdle });
var bytes = await page.ScreenshotAsync();
string base64 = Convert.ToBase64String(bytes);
Console.WriteLine(base64);
await browser.CloseAsync();
The .NET API returns byte[]; Convert.ToBase64String performs the complete conversion. Supplying a path saves the image, but is not required.
Choose the capture scope before encoding
Base64 represents exactly the bytes Playwright produced. Decide whether those bytes should describe the viewport, the whole page, or one element before calling the encoder.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Viewport screenshot
The default captures the currently visible viewport. Set the viewport when opening the page so screenshots are repeatable:
Rank #2
- AN AMAZING MAC AT A SURPRISING PRICE — With an incredibly portable and durable aluminum design, up to 16 hours of battery life,* and the A18 Pro chip, MacBook Neo is ready to go wherever school takes you.
- FOUR STUNNING COLORS. ONE DURABLE DESIGN — Choose from four beautiful colors — Silver, Blush, Citrus, or Indigo — each with a color-coordinated keyboard. And MacBook Neo is made with a durable recycled aluminum enclosure that helps it reach 60 percent recycled content by weight — the most ever in any Apple product.*
- FLY THROUGH EVERYDAY ASSIGNMENTS — Whether you’re cramming for finals, using Apple Intelligence* to summarize class notes, creating presentations, or even playing the latest Apple Arcade game,* MacBook Neo delivers the performance and AI capabilities you need to get things done.
- UP TO 16 HOURS OF BATTERY LIFE — MacBook Neo delivers all day battery life, so you can power through from early morning classes to late night study sessions without worrying about plugging in.
- A VIBRANT 13-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Neo supports 1 billion colors, so photos and videos pop and text is crisp for easy reading.
const page = await browser.newPage({ viewport: { width: 1280, height: 800 } });
const base64 = (await page.screenshot({ type: 'png' })).toString('base64');
Full-page screenshot
Use fullPage: true in JavaScript, full_page=True in Python, or the equivalent screenshot option in Java and .NET. Playwright scrolls through the document and stitches the scrollable content into one image.
// JavaScript
const bytes = await page.screenshot({ fullPage: true });
const base64 = bytes.toString('base64');
# Python
screenshot_bytes = await page.screenshot(full_page=True)
base64_string = base64.b64encode(screenshot_bytes).decode('ascii')
Very long pages create large images. Confirm that the receiving service accepts the resulting Base64 length, and consider capturing sections or an element when a single enormous image is unnecessary.
Element or locator screenshot
Capture a component rather than the entire page with a locator. The JavaScript guide documents locator.screenshot(); Python and the other bindings expose the corresponding locator or element screenshot methods.
Recommended Free Tools
const card = page.locator('[data-testid="invoice"]');
await card.waitFor({ state: 'visible' });
const base64 = (await card.screenshot({ type: 'png' })).toString('base64');
Waiting for visibility avoids encoding an empty placeholder or a partially rendered component.
Format, quality and data-URL decisions
PNG, JPEG and WebP
Playwright supports PNG, JPEG and WebP output where the installed binding and browser support them. PNG is lossless and is a safe default for text, interfaces and transparency. JPEG is usually smaller for photographs but does not support transparency. WebP can reduce size when your consumer accepts it. Quality settings apply to formats that support quality; check the API reference for your language and version.
Rank #3
- Performance: Powered by Intel Celeron N4500 dual-core processor with up to 2.8 GHz burst frequency and 4MB L3 cache, this HP Chromebook delivers smooth multitasking for everyday computing. With 4GB LPDDR4x-2933 RAM and Intel UHD Graphics, enjoy seamless web browsing, video streaming, and productivity apps. Chrome OS boots in seconds and updates automatically, keeping your laptop secure and running at peak performance for students, professionals, and home users.
- Immersive 14-Inch HD Display: Experience clear, vibrant visuals on the 14-inch diagonal HD (1366 x 768) anti-glare display with 250 nits brightness and 62.5% sRGB color accuracy. The micro-edge design maximizes your viewing area with an impressive 80% screen-to-body ratio, perfect for streaming movies, video calls, and document editing. The anti-glare coating reduces eye strain during extended use, making it ideal for all-day productivity and entertainment in any lighting condition.
- Advanced Connectivity & Ports: Stay connected with Wi-Fi 6 (2x2) for faster wireless speeds and Bluetooth 5.3 for seamless device pairing. Equipped with versatile ports including 1 USB Type-C 10Gbps (with USB Power Delivery and DisplayPort 1.4), 2 USB Type-A 5Gbps ports, 1 HDMI 1.4b, and 1 headphone/microphone combo jack. Connect external monitors, transfer files quickly, charge your device, and expand your workspace effortlessly for maximum productivity and flexibility.
- All-Day Battery & Premium Design: The battery keeps you powered throughout your day, while the included 45W USB Type-C power adapter ensures fast charging. Featuring a sleek modern grey finish with vertical brushing pattern on the keyboard deck, this lightweight 3.35 lb Chromebook combines style and portability. The full-size modern grey keyboard and HP Imagepad provide comfortable typing and precise navigation for work, school, or entertainment on the go.
- Enhanced Security & Multimedia: Built-in H1 secure microcontroller protects your data and privacy with enterprise-grade security. The HP True Vision 720p HD camera with integrated dual array digital microphones delivers crystal-clear video calls and online meetings. HD Audio with stereo speakers provides rich, immersive sound for music, videos, and calls. With 64GB eMMC storage, you have ample space for essential files while Chrome OS seamlessly integrates with Google Drive for cloud storage.
const jpegBase64 = (await page.screenshot({ type: 'jpeg', quality: 80 })).toString('base64');
const webpBase64 = (await page.screenshot({ type: 'webp', quality: 80 })).toString('base64');
Options such as CSS-versus-device scale, masking and background behavior are version-sensitive. For example, omitBackground (or the binding’s equivalent) is not applicable to JPEG. Verify option names in the relevant Python Page API or .NET Page API, and the corresponding language reference.
Raw Base64 versus a data URL
The official examples output raw Base64. A browser-facing consumer may instead require a data URL with a media-type prefix:
const bytes = await page.screenshot({ type: 'png' });
const dataUrl = `data:image/png;base64,${bytes.toString('base64')}`;
Use data:image/jpeg;base64, or data:image/webp;base64, when those are the actual output formats. Do not add a prefix if the receiving API expects only the encoded payload.
Make captures deterministic
- Wait for the right state: use
page.gotowith an appropriate load state, then wait for a selector, a specific response, or a short application-defined readiness condition. - Control viewport and device scale: the same CSS viewport can produce different pixel dimensions when device scale is changed.
- Handle fonts and animations: wait for web fonts and disable or pause animations when pixel-level consistency matters.
- Use stable content: hide timestamps, rotating adverts and random identifiers with masking or page CSS where your binding supports it.
- Close resources: use
try/finally(or language-specific resource management) so browser processes are closed after errors.
Memory, transport and performance considerations
Base64 expands binary data by roughly one third, and the encoded string may temporarily coexist with the original byte buffer. A full-page PNG can therefore consume substantially more memory than the visible image. For high-volume jobs, process one capture at a time, release references after sending, and prefer JPEG or WebP when lossless output is not required.
Do not log complete Base64 strings in production: logs become large and may expose private page content. Send the value directly in a request body, store it in a binary object store after decoding, or stream a file when the downstream interface supports it. If a service imposes request-size limits, upload the binary image or divide work into smaller element captures instead of wrapping everything in JSON.
Rank #4
- [INTEL POWERED CONTENT] - Built with a 8th Generation Hexa-Core Intel i5 and 32GB of DDR4 RAM; Modern, Windows 11 ready, with 4K support, Executive multitasking, media streaming and smooth, multi-tab web browsing; Perfect as an all-purpose multimedia computer; built for content creators; Plenty of RAM and Mass storage for photo and video editing powered by Intel HD 630
- [LATEST WIRELESS TECH] - This Dell Desktop Computer easily connects to the internet through the Built In WiFi / Bluetooth
- [SOLID STATE STORAGE] - This Dell Computer setup comes with an ultra-fast 1TB Solid State Drive (SSD); Setup as the primary boot device; Boot and load programs with lightning speed ; Additional expansion available
- [BUY & OWN WITH CONFIDENCE] - From the world's largest Microsoft Authorized Refurbisher; Quality Guarantee and Free Tech Support; Award-winning Customer Service; | Support Sustainable Business
- [MODERN HI-SPEED PORTS] - USB 3.0 (x4) | USB 2.0 (x4) | DisplayPort (x1) | HDMI Port (x1) | Audio Combo Jack (x1) | Audio Out (x1) | RJ-45 Ethernet (x1) | Internal SATA (x3)
Troubleshooting
“The result is empty, undefined or not a string”
Check that you awaited the screenshot promise and encoded the returned bytes, not the promise itself. In JavaScript, use (await page.screenshot()).toString('base64'). In Python, call await page.screenshot() in async code (or the synchronous API in a sync context).
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstall“Screenshot is taken before the page is ready”
networkidle is not a guarantee that client-side rendering is complete. Wait for a meaningful element, such as await page.locator('#dashboard').waitFor({ state: 'visible' }), or wait for the application’s ready signal. For delayed images, use a selector or an explicit delay only when there is no better readiness condition.
“Full-page output misses content”
Lazy-loaded content may require scrolling or an application-specific trigger before capture. Confirm that the content is in the document, wait for its locator, and then request fullPage/full_page. Fixed headers can appear repeatedly or overlap content; adjust page CSS or capture the relevant sections separately.
“The Base64 image will not display”
Confirm the media type matches the screenshot format and whether the consumer expects raw Base64 or a data URL. A raw value belongs in an API field; an HTML img source generally needs data:image/png;base64, (or the matching type).
“Memory usage keeps climbing”
Close each page and browser, avoid retaining old strings, and limit concurrency. Prefer an output format and capture scope that match the actual requirement. For very large pages, write to a path and upload the file if your transport does not require in-memory encoding.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Best Value
- 🖥POWERFUL PROCESSOR and SUPERIOR STORAGE: Configured with top of the Intel Core i5 processor for lightning-fast, reliable and consistent performance to ensure an exceptional PC experience. 16GB RAM memory to smoothly run multiple applications and browser tabs all at once. 2TB HDD storage space to store apps, games, photos, music, and movies. Loaded with 16GB to zip through multiple tasks in a hurry without lag.
- 🖥️New 22 Inch Full HD (1920x1080) LED monitor: with 75hz, High-Quality panel with quick refresh rate and response time. With 1080p resolution, you can enjoy gaming or a modern computing experience. 22 Inch monitor has a Smart Contrast to provide optimized image quality. Bezel-less and sleek design with glossy finish, crisp edge-to-edge visuals. Wide Viewing Angles for clarity from any viewpoint. VESA Mountable and built-in tilt options allow for a variety of monitor configurations.
- ⌨️ +🖱️ RGB KEYBOARD AND MOUSE | RGB SPEAKER: 3 LED Colors - Blue, red, green, Backlight LED Lights for use at night time, looks amazing. The keyboard mouse and speaker are responsive, reliable, and probably plastered in RGB lights. It's important you pick the right one for your desktop.
- 💿 WINDOWS 10 Pro LATEST: A new installation of the latest Microsoft Windows 11 Professional 64 Bit Operating System software, free of bloatware commonly installed from other manufacturers. As Microsoft's latest and best OS to date, Windows 10 Pro 64 Bit will maximize the utility of each PC for years to come. Optional software such as Anti-Virus and Office 365 can also be easily downloaded through the Microsoft Windows App Store.
“The option name is rejected”
Playwright bindings do not always spell options identically, and availability can change between versions. Consult the API reference for the language and installed package rather than copying an option from another binding unchanged.
Or skip the browser setup
If you only need a URL rendered and encoded or delivered by your application, ScreenshotNeo provides a website screenshot API. Its endpoint returns PNG, JPEG, WebP or PDF, while handling browser setup for you. The request can be made with cURL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for response handling and options. The same endpoint is available from Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
And Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
- Cookie banners, newsletter popups and chat widgets are removed before the shot; each cleanup step can be disabled.
- Bot checks or CAPTCHAs, blank pages, failed loads, timeouts and cache hits are not billed, and response headers identify the page verdict and billing status.
- An MCP server lets Claude, Cursor and other MCP clients call
take_screenshot,get_page_infoandcapture_pdf. - The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.
Create a free ScreenshotNeo account to try the 1,000 monthly screenshots without a card.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Quick implementation checklist
- Navigate to the target URL and wait for a state that represents a finished page.
- Select viewport, full-page or locator scope.
- Choose PNG, JPEG or WebP and any supported quality or masking options.
- Call the screenshot method without a path to receive bytes in memory.
- Use the language-native Base64 encoder without decoding binary data as text first.
- Add a data-URL prefix only when the receiving interface explicitly requires it.
- Close pages and browsers, and avoid logging the encoded image.
Frequently Asked Questions
Does Base64 change the screenshot quality?
No. Base64 is an encoding of the existing image bytes; quality is determined by the screenshot format and options selected before encoding.
Can I decode the string back to an image?
Yes. Decode the Base64 payload with your language’s Base64 decoder and write the resulting bytes as a file using the matching extension.
Should I use full-page capture for every screenshot?
No. Use the viewport for what a user sees, full-page for a document-length artifact, and a locator for a specific component. Smaller scopes reduce memory and transport size.
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.

