HTML Viewer

Paste HTML and see the page it makes, at desktop, tablet or phone width. Then check the same code against the standard.

The site your code comes from, so paths like /img/logo.png load in the preview. Your code is not changed.

Preview

JavaScript off

Nothing to show yet. Paste HTML above, or load the sample.

Validation

Checks the same code against the HTML standard with our HTML validator. Ctrl+Enter in the editor also works.

What the Viewer Does

Live preview

The page renders below the editor and follows every change, so you can adjust markup or inline CSS and see the result straight away.

Three widths

Full width, tablet at 768 px and phone at 390 px, to check media queries and layouts that break on small screens. The frame can also be resized in height.

Isolated from this site

The code runs in a sandbox with no origin of its own: no access to cookies, storage, this page or your session, and no pop-ups or form submissions.

Validated with one click

The same code goes through our HTML validator: every error and warning with its line, a click to select it in the editor, and a guide for the fix.

What the Sandbox Blocks

Previewing HTML means running somebody's markup inside your browser, and a careless previewer runs it as part of its own site. This one does not. The frame is created with the HTML sandbox attribute and without allow-same-origin, so the browser gives the page an opaque origin that matches nothing. We checked each of these in Chromium before publishing the tool:

  • cookies, localStorage, sessionStorage and IndexedDB throw a security error;
  • requests the page makes to this site carry no cookie, so they cannot act with your session;
  • the page cannot read or navigate this page, open windows or tabs, submit forms, or show alert() dialogs;
  • scripts do not run at all until you switch JavaScript on, and then only inside the sandbox.

What still happens is what any browser does with the page: images, stylesheets and fonts it references are fetched from their own servers, and clicking a plain link navigates the preview frame. Use Reload preview to bring the page back.

Viewer, Formatter or Validator?

Use this viewer to see what HTML looks like. Use the HTML formatter when the code itself is unreadable and needs indenting, or minifying for production. Use the HTML validator to check a live page by its address, or a long document with filters and an export. When the validator reports a problem, the HTML error guides show the wrong and right version of the code, from an unclosed tag to a missing alt attribute.

Frequently Asked Questions

How do I view an HTML file as a web page?
Open the file in a text editor, copy everything, and paste it into the box. The preview below renders it as a browser would and updates as you edit. Use the width buttons to see it at tablet (768 px) or phone (390 px) width, which is how media queries and responsive layouts are tested.
Is it safe to preview HTML I did not write?
The preview runs in a sandboxed frame with no origin of its own, so the code cannot read this site's cookies or storage, cannot send requests with your session, cannot open windows, submit forms, show dialogs or navigate this page. JavaScript is off unless you switch it on, and even then it stays inside that sandbox. Images and stylesheets it references are still loaded from wherever they point, exactly as they would be in a browser, so do not preview a page you would not open.
Why are my images broken in the preview?
Relative paths such as images/logo.png or /css/site.css only mean something relative to the site the page comes from. Enter that site's address in the field under the toolbar and they load from there. Your code is not changed: the address is added as a base for the preview only.
Does the preview run JavaScript?
Not by default. Tick Run JavaScript to execute the page's scripts. They run in an isolated origin, so code that needs cookies, localStorage or a login will behave as it would for a first-time visitor with storage blocked, and alert() does nothing.
Is my HTML uploaded?
The preview is drawn entirely in your browser. Only when you press Validate is the code sent to our validator, which checks it in memory and does not store it.
Why does the page look right but still have errors?
Browsers recover from broken markup silently: an unclosed tag or a misplaced element usually renders, but different browsers, screen readers and search engines may repair it differently. The validator reports what the standard says, with the line of each problem. Warnings are best practice and do not make the HTML invalid.
Can I preview a page from a URL?
Not here: the viewer renders code you paste. To check a live page, run its address through the HTML validator, or open it in your browser and use View Source to copy the HTML.

Related Tools