HTML Live Preview Online
Preview HTML, CSS and JavaScript in your browser, save the result safely, and capture a clean screenshot when your page is ready.
Use an online HTML editor with a preview pane. Paste your HTML, add CSS and JavaScript if the editor supports separate panes, then use its automatic preview or press Run. Before you close the tab, download the HTML or save a shareable project link; a live preview is not automatically a saved or published website.
What “HTML live preview online” means
An online live preview renders the code you are editing in a browser. Some tools update after a short pause; others update only when you press Run. W3Schools describes an editor for HTML, CSS and JavaScript with a Run control, while Gera Tools describes separate panes with an automatically updating preview. Check the trigger before assuming that every keystroke is rendered.
A preview is useful for a small page, a component experiment, documentation example or learning exercise. A multi-page project with a build step usually belongs in a local development workflow.
Choose an online HTML editor
| Question | Why it matters |
|---|---|
| Does it auto-run or require Run? | Auto-run is convenient; Run gives you control when scripts are expensive or incomplete. |
| One pane or HTML/CSS/JavaScript panes? | Separate panes match how many projects are organized. A single pane is faster for one-file examples. |
| How is work saved? | Browser-local autosave may not follow you to another device. Account saves or downloaded files are portable. |
| Can you export? | Look for copy, single-file HTML download, or a ZIP containing separate files. |
| Can you share or publish? | A link that reopens source code is different from a hosted public website. |
| What does the sandbox allow? | Script execution, same-origin access and network requests depend on iframe sandbox tokens. |
W3Schools is a practical example for short exercises: its editor lets you edit HTML, CSS and JavaScript and view the result in your browser. Its controls and account requirements can change, so verify them in the live tool.
Run a complete example
If the editor has separate panes, place each block in its matching pane. If it has one pane, use this complete document:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Live preview demo</title>
<style>
:root { color-scheme: light dark; }
body { font: 16px/1.5 system-ui, sans-serif; margin: 0; padding: 2rem; }
main { max-width: 42rem; margin: auto; }
button { padding: .6rem 1rem; cursor: pointer; }
#message { min-height: 1.5em; }
</style>
</head>
<body>
<main>
<h1>HTML live preview</h1>
<p>Edit this document and run the preview.</p>
<button id="hello" type="button">Change message</button>
<p id="message" aria-live="polite">Ready.</p>
</main>
<script>
document.querySelector('#hello').addEventListener('click', () => {
document.querySelector('#message').textContent = 'The JavaScript ran.';
});
</script>
</body>
</html>
With separate panes, put the style rules in CSS and the event listener in JavaScript. Press Run if the preview does not update automatically. Open the editor’s console when a script fails.
Save, export, share and publish
- Save the source. Download the HTML or use an account-based save. Browser-local autosave is tied to that browser and device.
- Export a portable copy. A single HTML file works for self-contained examples. Use a ZIP when you have separate CSS, JavaScript, fonts or images.
- Share source separately from output. A reopening link lets someone inspect or edit code; it does not necessarily host the result.
- Publish only when you need a public address. Hosting providers have their own terms and plan limits. Static.app describes a publish route that creates a live HTTPS address and states that free publishing lasts seven days; check its current plan before relying on that limit.
Understand the preview sandbox
Most editors render your code in an iframe. MDN explains that the sandbox attribute applies restrictions and that space-separated tokens lift particular restrictions. allow-scripts permits scripts; without allow-same-origin, the embedded document receives a special origin and same-origin checks fail. MDN strongly discourages combining allow-scripts and allow-same-origin for same-origin embedded content because the document can remove the sandbox.
These rules describe iframe mechanics, not a guarantee about any particular editor. Ask which tokens are enabled before assuming that cookies, storage, fetch requests or popups will work. If an editor uses srcdoc, MDN notes that relative URLs resolve against the embedding document’s URL, which can break relative images, stylesheets or scripts in a preview.
Read MDN’s sandbox documentation and its srcdoc reference for the exact browser behavior.
Common problems and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Nothing changes while typing | The editor requires Run or is waiting for a debounce delay. | Press Run, wait briefly, or reload the preview pane. |
| Styles are missing | CSS is in the wrong pane, a selector does not match, or a relative stylesheet URL cannot resolve. | Check the pane, inspect the element, and use an absolute URL or inline CSS for a quick test. |
| JavaScript does not run | A syntax error, script blocked by the sandbox, or code runs before the DOM exists. | Read the console, move code after the markup, or use defer. |
| Images show as broken | The URL is relative to the iframe base, the host blocks hotlinking, or mixed content is blocked. | Use HTTPS and verify the URL from the preview context. |
| Fetch or API calls fail | CORS policy, sandbox origin, authentication or a blocked request. | Use a server-side proxy for private APIs and inspect the browser network panel. Never put secret keys in client-side demo code. |
| Changes disappeared | Only temporary browser storage was used or the tab was cleared. | Download a copy or use named/account-based saves before switching devices. |
| The page looks different when published | The host uses a different base URL, headers, viewport or build process. | Test the published URL and fix absolute paths, font loading and responsive breakpoints. |
Performance, reliability and cost
- Keep examples small while iterating. Large bundles, animations and repeated network calls make auto-preview feel slow.
- Use an explicit Run action when incomplete JavaScript would otherwise execute on every edit.
- Use local files or a real project workflow when you need multiple routes, package installation, a build step, automated tests or dependable version history.
- Treat browser-local autosave as a convenience, not a backup. Download source or commit it to version control.
- Preview services are often free to use, but publishing, storage and private projects can have separate limits. Check the provider’s current terms.
Capture the rendered result
Once the preview is correct, you may need a PNG, JPEG, WebP or PDF for documentation, visual regression checks or a ticket. A browser screenshot tool can capture the rendered page after its fonts, images and scripts finish loading. For repeatable results, set the viewport, wait for a selector or network idle, and hide transient elements.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP or PDF. It removes cookie and consent banners, newsletter popups and chat widgets before capture. Bot checks, 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.
See the ScreenshotNeo API documentation for all options, including full-page capture with lazy images, CSS selectors, dark mode, device presets, retina scale, PDF paper and page ranges, custom CSS and JavaScript, clicks, waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, caching, signed links, asynchronous jobs, webhooks, bulk capture and usage data.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" \
-d access_key=YOUR_API_KEY \
--data-urlencode url=https://example.com \
-o shot.webp
Python
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://example.com"},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
Node.js
import { writeFile } from 'node:fs/promises';
const q = new URLSearchParams({
access_key: 'YOUR_API_KEY',
url: 'https://example.com'
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
await writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));
ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info and capture_pdf for Claude, Cursor and other MCP clients. Plans include 1,000 shots per month free with no card; paid plans start at $5 for 3,000 shots, and every feature is available on every plan. Create a free ScreenshotNeo account.
FAQ
What is the fastest way to preview HTML online?
Open an editor with a preview pane, paste a complete document, and press Run if it does not auto-update.
Can I preview CSS and JavaScript too?
Yes, when the editor supports those languages. Confirm whether they use separate panes or one document.
How do I save my HTML code from an online editor?
Download the HTML or use the editor’s account-based save. Browser-local autosave may be lost when you change browsers or devices.
Why does a preview differ from my published page?
The preview may use a different iframe origin, base URL, viewport, headers or build process. Test the published URL and correct paths and responsive styles.
Is a sandbox label enough to prove privacy?
No. Check the actual iframe tokens, storage behavior and network requests. “Sandboxed” describes restrictions, not the complete privacy posture of a service.


