HTML Viewer and Live Editor

A free online HTML viewer and editor that runs in your browser, with no signup and nothing to install. Paste or upload HTML and see it rendered straight away. Add CSS and JavaScript in their own panes, watch console messages and errors underneath, switch between phone, tablet and desktop widths, and share the result as a link or download it as one .html file. Your code runs in a locked-down frame that cannot reach this page, your cookies or your other tabs.

How it works

  1. Type or paste into the HTML, CSS and JavaScript panes, pick a starter, or upload an .html file (inline styles and scripts are moved into their own panes). You can also drop a file onto the editor.
  2. The preview rebuilds a moment after you stop typing. Turn off auto-run if you are writing code that is slow or unfinished, and press Run (or Ctrl/Cmd + Enter) when you are ready.
  3. Read console.log output, warnings and errors in the console under the preview. Repeated messages are grouped with a counter.
  4. Use the width buttons to see the page at 375, 768, 1024 or 1280 pixels, the way phones, tablets and laptops would show it.
  5. Format tidies the indentation of the pane you are in. Download saves everything as a single .html file, and Share copies a link that holds your code.

How the sandbox keeps your browser safe

Running code from a stranger's link is only safe if it cannot touch anything else. The preview here is an iframe whose content is passed in with srcdoc and whose sandbox attribute allows scripts and nothing more. Leaving out allow-same-origin is the important part: the browser gives the frame a fresh opaque origin, so it is treated like a different website with no cookies, no storage and no access to the we.inc page around it. Leaving out allow-popups, allow-forms, allow-modals and allow-top-navigation means it cannot open windows, send forms, show dialogs or redirect you.

The console works without weakening any of that. A small script added at the top of the preview wraps console.log and the other console methods, turns each value into plain text inside the frame, and posts that text out with postMessage. The viewer only accepts messages that come from the current preview frame and carry the ID of the current run, and shows them as text, never as HTML. Nothing ever flows the other way: the editor never runs your code itself, and never sends anything into the frame except the document you wrote.

Viewing an HTML file you already have

If someone sent you an .html file, an email template or a page saved from a browser, use Upload or drop it on the editor. The viewer moves inline <style> blocks into the CSS pane and plain inline <script> blocks into the JavaScript pane, so you can read each part on its own. Scripts loaded from a URL, modules and JSON data blocks stay where they are in the HTML. Relative links to images or stylesheets that sat next to the file on someone's computer will not load, because the viewer only has the one file; swap them for full URLs to see them.

Email templates are worth checking at 375 pixels as well as full width, since most email is read on phones. Remember that email apps support far less CSS than browsers, so a preview here shows how the HTML renders in a browser, not in every inbox.

From a quick prototype to a real website

A single HTML file is a fine way to try a layout, test a snippet from a tutorial or show a client an idea. When the idea needs several pages, a contact form that really sends, a domain and someone who can edit text without touching code, it is time to move to a site builder or a proper project. Download keeps a portable copy of your work at any point. The We.Inc box below turns a description of your page into a brief you can take into the We.Inc builder and review there first.

Tips

  • Tab inserts two spaces in the editors. To move focus out of an editor with the keyboard, press Escape and then Tab.
  • Turn on the Tailwind switch to use Tailwind utility classes without any setup. It loads the Tailwind Play script from its CDN, which is meant for trying ideas, not for a live site.
  • Paste a whole page, including <html> and <head>, into the HTML pane if you have one. The CSS and JavaScript panes are then added inside it rather than wrapped around it.
  • alert(), confirm() and prompt() are blocked by the sandbox. The viewer writes them to the console instead so you can still see they were called. Links to #sections scroll the preview; links to other pages are listed in the console instead of opening.
  • Keep share links for small examples. Everything is packed into the link itself, so a big page makes a very long URL that some chat apps cut short.

Frequently asked questions

How do I view an HTML file online?

Press Upload .html above, or drag the file onto the editor, and the page renders in the preview on the right. You can also open the file in a text editor, copy everything and paste it into the HTML pane. Images and stylesheets that the file loads from its own folder will not appear, because only the one file is opened; links to full https:// addresses do load.

How can I share an HTML page without hosting it?

Press Copy share link. The code is packed into the link itself, so whoever opens it sees your code and presses Run to preview it, with no account or upload on either side. For a large page, use Download .html and send the file instead, since very long links can be cut short by chat and email apps.

Can I check how my HTML looks on a phone?

Yes. The width buttons above the preview redraw the page at 375, 768, 1024 and 1280 pixels, which roughly match a phone, a tablet, a laptop and a desktop screen. It shows how the layout responds to the width; fonts and touch behaviour on a real phone can still differ slightly.

Is it safe to paste HTML or open a shared link here?

The preview is an iframe with sandbox="allow-scripts" and nothing else. Scripts can run, but the frame gets a unique, empty origin, so it cannot read this page, our cookies or storage, cannot open pop-ups or new tabs, cannot submit forms, and cannot move the main window to another site. Shared links never run on their own: you see the code first and press Run. The frame can still load images, fonts and scripts from the internet, so only run code you would be happy to open in any browser tab.

Is this HTML viewer free, and is my code uploaded?

It is free with no signup. Your code stays in your browser. Nothing is sent to We.Inc: drafts are kept in this browser's local storage, and share links keep the code after the # in the address, which browsers do not send to servers.

Why does localStorage or document.cookie throw an error in the preview?

Because the frame has no origin of its own, the browser refuses storage and cookies there with a SecurityError. That is the sandbox doing its job. To test code that uses storage, download the .html file and open it from your computer or a local server.

Can I use npm packages, React or ES modules?

You can load any library that ships a browser build from a CDN with a <script> tag in the HTML pane, and <script type="module"> with full CDN URLs works too. There is no build step, so JSX, TypeScript and bare imports such as import React from "react" will not run as written.

My page froze the tab. What happened?

An endless loop in your JavaScript can block the page, because some browsers run a sandboxed frame in the same process as the page around it. Reload, turn off auto-run before your code finishes loading from the saved draft, fix the loop and press Run.

What does Format do?

It re-indents the pane you are working in: HTML elements on their own lines with inline text kept together, CSS rules one declaration per line, and JavaScript with consistent braces and spacing. It does not change what the code does, and it does not check it for mistakes.

Related: HTML formatter, HTML validator, HTML minifier, CSS formatter, JavaScript formatter.

Start a 7-day free trial or see all free tools. On We.Inc you get a 7-day free trial, not a free plan: card needed, $0 today, cancel before it ends and you pay nothing. AI building is on paid plans from $20 a month.

More in Free Tools

Related guides

Product

Who It's For

Features

Resources

Company

View Sitemap