To turn code into a website preview image, first render the code as a webpage, then capture the rendered browser output. For a one-off image, open the page in a browser (or VS Code’s integrated browser) and save a screenshot. For repeatable previews, use Playwright to capture a fixed viewport, the full scrollable page, or one selected element.
What “turn code into an image” actually means
HTML, CSS and JavaScript source files are not themselves screenshots. A browser must parse the code, run scripts, load styles and assets, and render the resulting page. The image is a capture of that rendered state.
For a static page, open the HTML file directly or start the project’s local development server and use the preview URL it provides. A framework project must be started with that project’s documented command; there is no universal command or port. Once the page is visible, choose a manual browser capture for a quick visual or an automated capture when you need the same result again.
Choose a capture route
| Route | Best for | Setup | Repeatability and control |
|---|---|---|---|
| Browser or VS Code integrated browser | A quick review image, a design handoff, or checking the current state | Open the running page and use the browser’s screenshot command | Low setup; manual and dependent on the current window and machine |
| Playwright CLI | A one-off scripted capture with explicit viewport, target, filename and format options | Install Playwright and run its screenshot command against the preview URL | More repeatable than a manual capture, with command-line options |
| Playwright API | Build pipelines, visual review, regression tests and batches of URLs or states | Install a Playwright language binding and a browser | Highest control over navigation, waiting, selectors, scale and output |
Prepare the page before capturing
- Start the project using its own instructions. Frameworks differ in their scripts, ports and environment variables. Confirm that the development server reports a local URL.
- Open that URL in a browser. For a plain HTML file, opening the file itself may be sufficient; pages that use module imports, routing or server-side features generally need the project server.
- Verify the rendered state. Check fonts, images, data, responsive layout and interactive state before saving the image. A screenshot of a loading shell is still a screenshot, so make sure it is the state you intend to show.
- Pick the scope. Use a viewport capture for what is currently visible, full-page capture for the complete scrollable page, or an element capture for a card, form or section.
Take a manual browser screenshot
For a one-time preview, resize the browser to the desired viewport, navigate to the local preview URL, and use the browser’s built-in screenshot command. Browser menu labels vary by browser and operating system, but developer tools commonly provide a screenshot action for the visible viewport, the full page, or a selected node.
Recommended Free Tools
#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.
VS Code’s integrated browser provides an in-editor preview route. With the Live Preview extension, you can preview a web page in that browser, which is useful when you are editing a small static site and want to stay inside the editor.
Viewport capture
A viewport image shows only the area currently visible in the browser window. It is appropriate for a hero section, a fixed dashboard state or a shareable screen-sized preview. Set the window dimensions deliberately before capturing; otherwise the result will depend on the current window size.
Full-page capture
A full-page image includes the page’s scrollable content. It is useful for a landing page or long document, but it can become very tall and difficult to read at normal display size. Confirm that lazy-loaded content has appeared before saving; otherwise lower sections may be missing.
Element capture
Capture a specific card, form or section when the whole page would add irrelevant content. In developer tools, inspect the element and use the node screenshot action if your browser offers one. This keeps the image focused and makes dimensions easier to control.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Automate a preview with Playwright
Playwright’s screenshot API can navigate to a page, save a viewport image, capture the full scrollable page, or capture a locator or other target element. The URL below is an example; replace it with the URL and port used by your project.
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.
JavaScript API example
Install Playwright in the project, ensure the required browser is installed, and run a script such as:
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
await page.goto('http://localhost:3000');
await page.screenshot({ path: 'preview.png', fullPage: true });
await browser.close();
})();
The example creates a 1,440-by-900 CSS-pixel viewport and saves a full-page PNG. Remove fullPage: true for a viewport-only image. To capture one element, locate it and call its screenshot method:
const card = page.locator('[data-testid="pricing-card"]');
await card.screenshot({ path: 'pricing-card.png' });
Use a stable selector such as a data attribute rather than a fragile class generated by a framework.
Wait for the state you intend to show
Navigation completing does not always mean that the useful content is ready. If data, images or a component load asynchronously, wait for the relevant element or page state before the screenshot. A selector wait is more specific than an arbitrary delay when you know which element proves readiness. If the page has animations, freeze or wait for the final state so repeated captures do not differ.
Playwright CLI
The Playwright CLI supports screenshot commands with viewport settings, full-page capture, target elements, output filenames, image formats and high-resolution options. A CLI command is convenient for a single scripted capture; the API is better when navigation, authentication, waits or multiple states are part of the workflow. Full-page capture and a target-element capture are alternatives, not a combination.
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.
Choose PNG, JPEG or WebP
| Format | Use it when | Important limitation or option |
|---|---|---|
| PNG | You want lossless text and interface detail, or need transparency | Usually larger than a lossy photographic image |
| JPEG | A photographic page or smaller output matters more than lossless edges | Does not support a transparent background |
| WebP | You want modern compression and can choose a quality level | Playwright documents quality control; quality 100 produces lossless WebP |
Playwright can infer the screenshot type from the output filename where applicable. Choose the format based on the destination: PNG for crisp UI documentation, JPEG for suitable photographic content, and WebP when supported by the consuming system and you want a size/quality trade-off.
Control resolution with CSS or device scale
Playwright’s scale option controls whether output uses one pixel per CSS pixel (css) or device pixels (device). CSS scale keeps the image aligned with the page’s declared dimensions and is generally smaller. Device scale can produce a larger, higher-resolution image, especially on high-DPI displays.
Free tools Windows power users keep installed
One-click scans. No signup required.
Use CSS scale when the preview will be displayed at the same logical dimensions as the page. Use device scale when a sharper asset is needed for zooming or high-density displays, and verify the resulting pixel dimensions before committing it to a repository or documentation system.
Make automated screenshots reproducible
- Fix the viewport. A responsive layout can change substantially between widths.
- Keep the browser and operating environment consistent. Rendering can vary with operating system, browser version, settings, hardware, power source and headless mode. Create reference images and compare them in the same environment whenever possible.
- Control volatile content. Current timestamps, rotating banners, random identifiers, ads and live data can change between runs. Hide or mask such regions, or use screenshot styles designed for visual comparison.
- Use deterministic data. A local fixture or stable test account is easier to compare than a production feed.
- Wait for meaningful readiness. Capture after the key selector exists and images or fonts needed for the composition have loaded.
Troubleshoot incomplete or unexpected images
The image is blank
Confirm that the project server is running, the URL and port are correct, and the browser can reach it from the environment running Playwright. A page that failed navigation or rendered an error route will still produce an image.
Only the top portion appears
Check whether you requested a viewport screenshot when you meant a full-page screenshot. For an element image, verify that the selector identifies the intended node. Full-page capture cannot be combined with a target element.
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
Content is missing below the fold
Lazy-loaded images and components may not exist until they approach the viewport. Scroll or wait for the relevant content before capturing, and confirm that the page’s own loading state has finished.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →The screenshot catches a spinner or half-rendered UI
Wait for the element that represents the completed state, or wait for the application’s documented readiness signal. Avoid choosing a delay that is shorter than the slowest normal load; a selector or explicit state is usually more reliable.
Two runs do not match
Compare viewport, browser version, operating system, headless mode, device scale, fonts and dynamic data. Remove or mask volatile regions and run the baseline and comparison in the same environment.
The file is blurry or unexpectedly huge
Inspect the selected scale and device-pixel ratio. CSS scale produces CSS-aligned output; device scale may multiply pixel dimensions. Also check whether the filename selected PNG, JPEG or WebP and whether the consuming application resizes it again.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
ScreenshotNeo provides a website screenshot API when you want a rendered image without maintaining browser-launch code. It can accept consent banners before capture and remove more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.
Its API supports full-page captures with lazy images loaded, CSS-selector element captures, dark mode, device presets or custom viewports, retina scale, PNG/JPEG/WebP output, PDF, custom CSS and JavaScript, clicks, selector or network-idle waits, request and resource blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, configurable-TTL caching, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify a migration. An MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.
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.
Use the ScreenshotNeo API documentation for the full parameter reference. A basic cURL request is:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The same request in 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 in 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}`);
The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing provides two months free, and every feature is available on every plan. Sign up for the free ScreenshotNeo plan to try the API without adding a card.
Which method should you use?
- Choose a browser screenshot when you need one image immediately and can inspect the page manually.
- Choose Playwright when screenshots must be regenerated, compared in visual tests, or captured in several states with controlled dimensions.
- Choose ScreenshotNeo when you want an HTTP call, built-in page cleanup, usage-aware billing and an MCP option instead of managing a browser environment.
Frequently Asked Questions
Can I screenshot source code without running it?
No. A website preview image represents the browser-rendered result, so the code must be opened as a page or served by the project before capture.
Should I use a viewport or full-page screenshot for documentation?
Use a viewport for a screen-sized state and full-page for a complete scrollable document. Select an element when only one component matters.
Why does the same page look different on two computers?
Browser version, operating system, fonts, hardware, headless mode, viewport, device scale and dynamic content can all change rendering. Keep the comparison environment consistent.
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.

