Skip to content

HTML Runner & Viewer — Run HTML, CSS & JavaScript Online

Run HTML online: paste HTML, CSS and JavaScript and see it live. Paste a whole ChatGPT reply and the code is pulled out. The console shows errors by line number—click to jump there. Nothing is uploaded.

Runs in Browser Free
Runs in an isolated sandbox in your browser. Your code is not sent to our servers; drafts stay in this browser.

Ctrl/⌘ + Enter to run · Tab indents · press Esc, then Tab, to leave the editor

Not run yet
Console
Console forwarding, error line mapping, AI reply splitting, local-file warnings, failed external resources, storage stand-ins, anchors and relative links, legacy-encoding file import, draft restore and the freeze guard were tested end to end in Chromium and WebKit in November 2026. — Go Tools Engineering Team · Nov 16, 2026

Built and verified by the Go Tools engineering team.

HTML runner quick answers

How do I run HTML code online?

Paste it and it runs Paste the code into the HTML panel above. The preview refreshes about 0.7 seconds after you stop typing, or press Ctrl+Enter (⌘+Enter on a Mac) to run it at once. CSS and JavaScript can stay inside the HTML or go into the CSS and JavaScript panels.

How do I run HTML that ChatGPT or another AI wrote?

Paste the whole reply Paste the whole reply from ChatGPT, Claude, Gemini or DeepSeek. The tool drops the ```html fences and the explanation around them, puts the HTML, CSS and JS blocks into their own panels and runs the page. If you did not want the split, click Paste as is on the notice.

Why is my page blank?

Check the console first Three common causes: a script error (the console gives the line number—click it to jump there); an external script that did not load (the console lists addresses that failed or are still loading); or links to local files such as style.css and script.js, which do not exist when the page runs online.

How do I view an .html file online?

Open it or drag it in Double-clicking an .html file opens it in your browser; to see its console errors as well, click Open file or drag the file onto the tool. Older pages saved in a legacy encoding such as GBK, Big5 or Shift_JIS are detected from their bytes or their meta charset, so the text is not garbled.

Is it safe to run code someone sent me?

It runs in an isolated sandbox The code runs in an isolated sandbox iframe. It cannot read this site’s page, storage or cookies, and it cannot navigate the tab away. Nothing is uploaded to our servers. Like any web page, though, it can still use the network, so read unfamiliar code before you run it.

What is an online HTML runner?

An online HTML runner lets you see what a piece of HTML—with its CSS and JavaScript—does without creating a file or installing an editor. It is handy for checking a tutorial snippet, tuning a CSS layout, or seeing what an AI-generated game or dashboard actually looks like. It also works as an HTML viewer for an .html file someone sent you.

Rendering the page is only half the job. When the code breaks, the page is often just blank; a phone has no developer tools, and on a computer you have to open them with F12 to see the error. So this runner puts the page’s console under the preview: console.log output, uncaught errors and resources that failed to load all show up there. Each script error says whether it is in the HTML or JavaScript panel and on which line, and clicking it puts the cursor on that line.

The code runs in an isolated sandbox iframe: it cannot reach this site’s page or storage, it is not uploaded to our servers, and drafts are kept only in your own browser.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Demo</title>
</head>
<body>
  <h1>Hello, world</h1>
  <button id="btn">Click me</button>
  <script>
    document.getElementById('btn').onclick = () => {
      console.log('clicked');
    };
  </script>
</body>
</html>

HTML runner features

A console that points to the panel and line

The console under the preview shows console.log, info, warn and error, console.table and console.assert, with objects and arrays expanded. Uncaught errors are listed with the panel (HTML or JavaScript) and line number; click the line number and the editor selects that line. Unhandled promise rejections are listed too. Full error details show in Chrome, Edge and Safari alike.

Paste a whole AI reply

Replies copied from ChatGPT, Claude or DeepSeek usually wrap the code in ```html fences with explanations around it, or split it into index.html, style.css and script.js. Paste the whole reply into an empty panel and only the code blocks are kept, each in its own panel. An ordinary web page that is not an AI reply is left untouched.

Tells you what a blank page is missing

When an external script or stylesheet fails to load, the console gives its address; when the page is still waiting for an external resource after 5 seconds, the console lists what has not finished loading. Links to local files such as style.css or logo.png are flagged before the run: they do not exist online.

localStorage works; anchor links stay put

A sandboxed page normally throws the moment it reads localStorage, and many small games that keep a high score there go blank. This runner gives the page an in-memory localStorage, sessionStorage and cookie jar that reset when the preview reloads. Links to #anchors scroll inside the preview, and relative links to other pages are stopped and explained in the console.

HTML preview: phone width, full screen, download

Switch the preview to phone (375 px), tablet (768 px) or desktop (1280 px) width, or view it full screen. Download .html merges the three panels into one standalone page you can double-click; when the code has no meta charset, a UTF-8 byte order mark is added so non-English text is not garbled.

Edits like a code editor

Syntax colors, line numbers, Tab and multi-line indent, auto-indent on Enter, and one-click formatting for HTML, CSS and JS. Drafts are saved in your browser and are still there when you come back. If the last run froze the page (an infinite loop, say), the next visit does not auto-run the same code again.

HTML runner examples: errors by line, AI replies, local files

An error located to its line

<h1>List</h1>
<ul id="list"></ul>
<script>
  const items = ['apple', 'banana'];
  const list = document.querySelector('#lsit');
  items.forEach(t => list.append(t));
</script>
Console: Uncaught TypeError: Cannot read properties of null (reading 'append')    HTML line 6

Line 5 misspells the selector as #lsit, so querySelector returns null and the error only appears on line 6, where append is called. Click “HTML line 6” and the editor selects that line.

A pasted AI reply split into three panels

Sure! Here is the code:
```html
<button id="go">Start</button>
```
```css
button { padding: 8px 16px; }
```
```javascript
document.getElementById('go').onclick = () => alert('Go!');
```
Save these as three files.
HTML panel: <button id="go">Start</button>
CSS panel: button { padding: 8px 16px; }
JavaScript panel: document.getElementById('go').onclick = () => alert('Go!');

The text outside the fences is dropped and each code block goes into its own panel, then the page runs. If you did not want the split, click Paste as is on the notice.

Links to local files flagged before the run

<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
<img src="logo.png" alt="logo">
Your code links to local files: style.css, script.js, logo.png. They do not exist here. Paste CSS and JS into their tabs; use a web address or Base64 for images.

Paste the contents of style.css into the CSS panel and script.js into the JavaScript panel. For the image, turn it into a data URI with Image to Base64 and put that in src.

Objects and arrays in the console

<script>
  console.log('user', { name: 'Ada', tags: ['a', 'b'] });
  console.table([{ id: 1 }, { id: 2 }]);
  console.assert(1 > 2, '1 is not greater than 2');
</script>
user {name: "Ada", tags: ["a", "b"]}
[{id: 1}, {id: 2}]
Assertion failed 1 is not greater than 2

Objects, arrays, Maps, Sets, DOM elements and Errors are turned into readable text; circular references print as [Circular] instead of hanging the page.

How to run HTML online

  1. 1

    Paste or type your code

    Paste a whole page into the HTML panel. CSS and JavaScript can stay inside the HTML or go into the CSS and JavaScript panels. A whole reply copied from an AI chat works too.

  2. 2

    Watch the preview

    Auto-run is on by default and refreshes the preview about 0.7 seconds after you stop typing. With auto-run off, click Run or press Ctrl+Enter (⌘+Enter).

  3. 3

    Read the console

    console.log output and errors appear under the preview. The “HTML line N” after an error is a link: click it to jump to the line.

  4. 4

    Adjust the preview

    Use Preview width to switch between phone, tablet and desktop widths, or click Full screen.

  5. 5

    Keep or download it

    Drafts are saved in your browser automatically. Download .html gives you a standalone page you can double-click to open.

Common HTML page problems: blank pages, missing styles, links

A wrong selector, then a method call on null

document.querySelector returns null when nothing matches; calling .append or .addEventListener on it throws, and nothing after it runs, so the page seems to do nothing. Check the selector on the line the console gives, or make sure the script comes after the element.

✗ Wrong
<script>
  document.querySelector('#app').innerHTML = 'hi';
</script>
<div id="app"></div>
✓ Correct
<div id="app"></div>
<script>
  document.querySelector('#app').innerHTML = 'hi';
</script>

Pasting an AI reply, fences and all, into one file

Code fences and explanations are not HTML: they appear as text at the top of the page, and CSS and JS blocks turn into paragraphs. Pasted whole into an empty panel here, the reply is split automatically; in other editors, copy only what is inside the code blocks.

✗ Wrong
```html
<h1>Hi</h1>
```
✓ Correct
<h1>Hi</h1>

Linking to local files that are not there

AI chats often split a page into index.html, style.css and script.js. Online, only the code you pasted exists, so <link href="style.css"> and <script src="script.js"> load nothing and the styles and interactions silently go missing. Put their contents into the CSS and JavaScript panels, or inline them in <style> and <script> tags.

✗ Wrong
<link rel="stylesheet" href="style.css">
✓ Correct
<style>
  body { margin: 0; }
</style>

An external CDN script that never loaded

Libraries such as Vue, Chart.js or Tailwind come from an external CDN. If your network cannot reach that CDN, code that depends on it throws “… is not defined” or the page stays blank. The console lists addresses that failed or are still loading after 5 seconds; switch to a CDN your network can reach.

✗ Wrong
<script src="https://cdn.example.com/vue.global.js"></script>
<script>Vue.createApp({}).mount('#app')</script>
✓ Correct
Console: Failed to load https://cdn.example.com/vue.global.js
→ use a CDN address your network can reach, then run again

Anchor links and multi-page links

An online run has one page. Anchors such as href="#section" scroll inside the preview as usual; relative links to other pages such as href="about.html" have no target here, so they are stopped and explained in the console. Run each page of a multi-page project on its own.

✗ Wrong
<a href="about.html">About</a>
✓ Correct
<a href="#about">About</a>
…
<section id="about">…</section>

When to use an online HTML runner

Check pages, games and charts an AI wrote
Ask ChatGPT, Claude or DeepSeek for a snake game, a countdown page or a dashboard, paste the whole reply and see it run. When something breaks, sending the exact error and line number back to the AI makes the fix far more likely to work.
Learn HTML, CSS and JavaScript
Run tutorial snippets and change them in place. console.log output appears on the page, so you do not need the browser’s developer tools.
Tune CSS layouts for phones
Switch the preview to 375 px to see whether a flex or grid layout wraps and whether text overflows; change a line of CSS and see the result 0.7 seconds later.
Open an .html file from your computer
Preview a page someone sent you or a report a tool exported, and see its console errors too. Pages saved in a legacy encoding still show the right characters.
Build a minimal reproduction
Before asking for help or filing an issue, cut the problem down to a few lines of HTML and JS, confirm here that it still reproduces, then download the .html or share the code.

How the HTML runner works

A sandboxed iframe keeps your code apart from this site
Every run creates a new iframe whose sandbox allows scripts, dialogs (alert, confirm, prompt), forms, pop-ups, pointer lock and downloads—but not allow-same-origin or allow-top-navigation. Your page therefore runs as its own opaque origin: it cannot read this site’s DOM, localStorage or cookies, and it cannot navigate the tab away. The previous iframe is removed on the next run, so its timers, animations and sounds stop with it.
Why the line numbers match your code
The console bridge is placed at the very start of line 1 (right after the DOCTYPE, if there is one) and contains no line breaks, so your code does not move down a line. The CSS and JavaScript panels are appended after the HTML, and error line numbers are mapped back to the panel they came from. In Chrome, Edge and Firefox the preview is an srcdoc document, so APIs that need a secure context, such as crypto.randomUUID, work as usual. In Safari it is loaded from a data: URL instead: in our tests WebKit, the engine behind Safari, reports every uncaught error in an srcdoc document only as “Script error.” with no line.
How the console is forwarded
The page’s console methods are wrapped. Arguments are turned into text inside the sandbox (objects three levels deep, at most 100 array items, circular references as [Circular]) and sent with postMessage. The tool accepts only messages from the current preview that carry this run’s random token, and shows them only as text. Console output is limited to 500 messages per second and the rest is only counted, so a console.log in an infinite loop or in every animation frame cannot drag the page down; errors are counted separately, so a flood of output never hides them.
localStorage, sessionStorage and cookies in the sandbox
In an opaque-origin page, reading localStorage or sessionStorage throws a SecurityError; writing document.cookie throws in Chromium and is silently dropped in Safari. Before your code runs, the tool swaps in in-memory stand-ins: getItem and setItem, the localStorage.key = value form and document.cookie all work, and the data is cleared when the preview reloads.
Detecting a file’s encoding
When you open an .html file, the encoding is taken from, in order: a byte order mark; UTF-8, if the bytes are valid UTF-8; a <meta charset> in the first 1024 bytes (the same range a browser pre-scans), which can name any encoding the browser knows, such as GB2312, Big5 or Shift_JIS; and otherwise the bytes themselves, choosing between GBK and UTF-16. The detection is shared with this site’s Encoding Converter.

Practical tips for HTML pages

Give full pages a DOCTYPE and a meta viewport
<!DOCTYPE html> keeps the browser in standards mode, and <meta name="viewport" content="width=device-width, initial-scale=1"> decides whether the page is shrunk in the phone-width preview. Both matter just as much when you save the code to a file.
Put scripts after the elements they use
A script in <head> runs before the elements in <body> exist. Move the <script> to just before </body>, or use defer or DOMContentLoaded.
Send the AI the line number and the exact error
“HTML line 12: TypeError: Cannot read properties of null” is far more useful than “the page does not work”. Copy the error text and that line of code from the console, and the AI is much more likely to fix it in one go.
Turn off auto-run for big edits
When you are making large changes, or the code has loops and animations, switch auto-run off, finish editing, then press Ctrl+Enter, so half-written code is not run over and over.
Format before you share or ship
Format tidies the current panel with a 2-space indent and makes one-line HTML readable again. To minify it instead, use the HTML formatter and minifier.

HTML runner FAQ

How is this different from double-clicking an .html file?
The result is essentially the same. The differences: you do not have to save a file to see a change, the console is on the page instead of in developer tools, and errors link to their line. On the other hand, online there are no other files from your computer (style.css, images…) and no lasting localStorage; when you need those, download the .html and open it locally.
Does it run JavaScript and CSS?
Yes. Write everything in one HTML document (<style> and <script> tags) or use the CSS and JavaScript panels: the CSS panel is added to the page as a stylesheet, and the JavaScript panel runs after the HTML has been parsed. Note that a CSS mistake does not raise an error: the browser just ignores that rule, so nothing shows in the console. If a style does not apply, check the property name and units first.
Can I use Vue, React, jQuery or Chart.js from a CDN?
Yes. Load them with <script src="…"> or <script type="module">; the page can use the network. If your network cannot reach a CDN, the console shows the address that failed or is still loading, and you can switch to a CDN you can reach.
Is my code uploaded anywhere?
No. The code runs in your browser and is not sent to our servers. Drafts are kept in your browser’s localStorage; Clear empties the current panel. Note that if your own code requests external addresses (a CDN, an API), those requests are made as usual.
Why does localStorage data disappear?
The preview runs in an isolated sandbox, and the browser does not let it use the real localStorage. The tool provides an in-memory stand-in so code that relies on localStorage still runs, but it is cleared on every run. If you need data to persist, download the page and run it locally.
Does it work on a phone?
Yes. On a phone the editor, preview and console are stacked, and you can paste code and run it. On a computer, choosing the Phone · 375 width shows how the page looks at phone width.
Why does clicking a link do nothing?
Relative links to other pages (such as about.html) have no target in an online run, so they are stopped and explained in the console instead of leaving a blank preview. Links to #anchors scroll as usual, and links starting with http:// or https:// open in a new tab.
I wrote an infinite loop and the page froze. What now?
In current Chrome the preview runs in a separate process: if it stops responding for 3 seconds, the tool says so and offers a Stop preview button. It does not stop the preview on its own, because a dialog or a DevTools breakpoint in the preview looks the same from outside. In Safari, Firefox and some other browsers an infinite loop freezes the whole tab; close it and open the tool again. Your code is saved before each run, so nothing is lost, and the tool notices that the last run never finished: it turns auto-run off and tells you, so you can remove the loop before running again.
Can it run PHP or Python?
No. Browsers run only HTML, CSS and JavaScript; PHP, Python and JSP need a server, and a browser does not run the code inside <?php ?>.
An .html file I opened shows garbled text. What can I do?
The tool reads the byte order mark, the file’s <meta charset> and the bytes themselves to tell UTF-8, GBK and UTF-16 apart. If the text is still garbled, the file was probably converted with the wrong encoding at some point; try recovering it with the Encoding Converter.

Related Tools

View all tools →