An HTML preview gives you a fast way to render a small document without creating a project or publishing a page. Edit the sample markup and the preview updates after a short pause, so you can check structure, embedded CSS, and simple interactions in one browser tab.
The in-page result is placed in a sandboxed iframe. JavaScript is disabled initially and can be enabled for the preview when an interaction needs testing. This is useful for isolated experiments, but it is not a substitute for testing inside the application, stylesheet stack, content security policy, and browser matrix where the code will ship.
How to Use the HTML Preview
Edit a document, choose its test width, and decide whether its scripts may run.
- Type or paste markup into the HTML textarea; the Preview updates about 400 milliseconds after input stops.
- Leave Run scripts in the preview unchecked to render with scripts disabled, or check it to test JavaScript inside the isolated iframe.
- Choose Full, Phone (390 px), or Tablet (768 px) from Preview width.
- Read the status below the tool to confirm whether scripts are off or running in an isolated sandbox.
- After interacting with the tool, select Open in new tab to open the current HTML from a temporary local blob URL.
How an HTML Live Preview Renders a Document
The editor assigns the complete input to an iframe through srcdoc. The browser parses it as an HTML document, applies any embedded <style> rules, and renders its body. A full document with a doctype, head, and body works, but a short fragment also renders because the HTML parser supplies omitted document structure.
The result follows browser parsing rules rather than preserving source text exactly. Browsers repair some malformed nesting, insert implied elements, and ignore markup they cannot place in the parsed tree. A plausible-looking preview therefore does not prove that the source is valid HTML. Use validation and developer tools when exact structure matters.
The tool refreshes the whole iframe after an edit, so state inside the previous preview is lost. Form values, timers, and DOM mutations return to whatever the source declares. That makes repeatable snippets convenient, but it differs from hot module replacement in an application, where component state may survive an update.
For readable source before testing, use the HTML beautifier. If the target is a React component rather than a standalone document, convert the markup with HTML to JSX and review the result in its real component context.
Sandbox Boundaries and Script Safety
With Run scripts in the preview unchecked, the iframe has an empty sandbox value. Scripts, forms, popups, downloads, and top-level navigation remain restricted. When the checkbox is enabled, the tool adds allow-scripts and allow-modals; it does not add allow-same-origin, so the document keeps an opaque origin and cannot read this page's cookies or storage through same-origin access.
That isolation is deliberately narrow. Script code can still consume CPU, display modal dialogs, and attempt network requests. Images, stylesheets, fonts, and other external URLs in the entered HTML may also contact their hosts even when JavaScript is off. Do not interpret local rendering as an offline guarantee for resources referenced by the document.
Open in new tab deserves separate treatment. It creates a temporary text/html Blob URL, opens it with noopener, and revokes the URL after 60 seconds. The new tab is not the sandboxed iframe, and the Run scripts in the preview setting does not rewrite or disable scripts in that document. Inspect unfamiliar markup before using this action, because active content can execute in the new tab under normal browser rules.
The editor text itself is processed locally and is not uploaded by the tool. Even so, paste redacted examples when possible: a preview containing real credentials, private customer data, or authenticated external URLs can still expose information through displayed content or resource requests.
Responsive Widths, Viewports, and Layout Limits
The Preview width control changes the iframe element to 100%, 390px, or 768px. Those sizes are useful checkpoints for narrow and medium layouts. They do not emulate a specific device, browser engine, pixel density, touch input, virtual keyboard, network speed, or operating-system font metrics.
Media queries evaluate against the iframe viewport, so width-based breakpoints can be exercised. The fixed-width options may overflow the tool area on a screen narrower than the selected size; that is a container constraint, not necessarily a defect in the entered page. A document's own viewport metadata and CSS still influence its behavior.
Treat the presets as quick probes, not a responsive test suite. Check content just below and above important breakpoints, use browser device emulation for input and device characteristics, and test real devices when touch behavior or mobile browser chrome affects the feature.
The preview also lacks the surrounding application. Inherited styles, custom fonts, CSS variables, module imports, routing, and framework runtime code are present only if the pasted document defines or loads them. A component that looks correct in isolation can still conflict with global selectors or layout constraints after integration.
Common HTML Preview Problems and Debugging Steps
If styling is missing, confirm that the CSS is inside a <style> element or points to a reachable stylesheet. Relative URLs resolve in the context of the srcdoc document, which may not match the directory of the project you copied from. Prefer a self-contained reduced example while diagnosing layout.
If a button does nothing, first check Run scripts in the preview. Then inspect syntax errors and remember that sandbox restrictions still block forms, popups, downloads, and top navigation because the corresponding permissions are not enabled. The tool displays the rendered page, but it does not provide a console or surface runtime exceptions in its status message.
Malformed HTML can produce surprising but renderable output. Missing closing tags, nested interactive elements, and table content in the wrong location may be repaired differently from what the source suggests. Reduce the snippet, validate the markup, and inspect the parsed DOM rather than relying only on pixels.
Finally, a successful isolated preview says little about accessibility or production readiness. Check keyboard order, labels, semantic landmarks, focus visibility, reduced-motion behavior, and contrast in the target application. Rendering is only the first test.
Frequently Asked Questions
Does the HTML preview run JavaScript?
JavaScript is off initially. Checking Run scripts in the preview reloads the iframe with allow-scripts allow-modals, while leaving it without allow-same-origin. Opening the document in a new tab is separate: the blob document is not placed in that iframe sandbox, so review scripts before opening it.
Is the preview isolated from the ParseCode page?
The in-page preview uses a sandboxed iframe without allow-same-origin, which prevents ordinary same-origin access to the parent page's storage and cookies. With scripts enabled, code can still run, show modals, use CPU, and request external resources. Sandbox isolation reduces capabilities; it does not make hostile code harmless.
Why does my relative image or stylesheet not load?
Relative URLs are resolved from the preview document's browsing context, not from the original file's project directory. The referenced asset may therefore be absent or resolve somewhere unexpected. For diagnosis, use an embedded style or an explicit URL that you understand, and remember that an external URL creates a network request.
Do Phone and Tablet modes emulate real devices?
No. Phone (390 px) and Tablet (768 px) change only the iframe width. They do not emulate a device's user agent, pixel ratio, touch hardware, performance, safe areas, or mobile browser interface, so follow up with device emulation and real-device checks where those factors matter.
Is my HTML uploaded when I preview it?
The tool assigns the text directly to an iframe in your browser, and Open in new tab creates a local blob URL. The tool does not upload the editor contents to a conversion service. However, resources referenced by your HTML can make their own network requests, so redact sensitive data and inspect external URLs.
References: WHATWG HTML Standard: the iframe element · MDN: Blob URLs.