Skip to content

HTML Editor

Preview updates as you type

Preview

Online HTML Editor: Run and Test Your Code

What is an online HTML editor?

It’s a little coding playground in your browser. You write HTML, CSS and JavaScript in three tabs on the left, and the result shows up on the right as you type. No setup, no files, no refreshing.

It’s perfect for trying out an idea, practising what you learned in a tutorial, building a quick demo for a teammate, or testing a bug in isolation before you fight with it in your real project. When you’re happy, download everything as one .html file or share it with a link.

Run, Test or “Compile” HTML Online

People call this an HTML runner, an HTML tester, an HTML playground or an online HTML compiler. It’s all the same idea: paste your code and see what it does. One thing to know: HTML isn’t really compiled. The browser reads it and draws the page straight away, and that’s exactly what the preview on the right does. Your JavaScript runs there too, inside a sandboxed frame, so you can test buttons, forms and small scripts without setting anything up.

Running your code doesn’t check it for mistakes, though. Type <b>Fresh coffee without the closing </b> and the preview still shows bold text, because browsers work around missing tags. The HTML Validator points out the tag you forgot to close.

How to Use the Online HTML Editor

Four quick steps. Copy the little examples into the editor as you go.

Step 1 Write Your HTML

Start in the HTML tab. You don’t need the whole <html> and <body> setup. Just write the part you care about.

Try it: a small card

<div class="card">
  <h2>Ada Lovelace</h2>
  <p>Wrote the first computer program.</p>
</div>

Step 2 Style It with CSS

Switch to the CSS tab and add your styles. They’re applied to the preview right away, so you can nudge a padding or a color and see the change instantly.

On your own site, you’d usually keep these styles in a separate file. Here’s how to link CSS to HTML when you get there.

Try it: paste this into the CSS tab

.card {
  max-width: 260px;
  padding: 16px;
  border-radius: 12px;
  background: #f7fee7;
  border: 1px solid #a3e635;
  font-family: system-ui;
}

The card now looks like this:

Step 3 Add Some JavaScript

The JS tab runs after your HTML loads, so you can grab elements by id and make them do things. Press Ctrl + Enter while you’re in a code tab to run it again, or untick Auto run if you’d rather run it by hand.

To use a separate .js file on your site, see how to link JavaScript to HTML. For JavaScript on its own, the JavaScript Playground shows your console messages on the page.

Try it: a click counter

<button id="count">Clicked 0 times</button>
<script>
  let n = 0;
  document.getElementById('count').onclick = (e) => {
    n++;
    e.target.textContent = 'Clicked ' + n + ' times';
  };
</script>

Go ahead, click it:

💡 In the editor you’d put the button in the HTML tab and only the code between the script tags in the JS tab.

Step 4 Check, Download or Share

Your page works? A few things you can do next:

  • Check other screens: switch the preview to Tablet or Mobile to see how it holds up.
  • Download: get one .html file with the code from your CSS and JS tabs inside it. It opens in any browser.
  • Share: create a link to a copy of all three tabs.
  • Tidy up: paste the result into the HTML Formatter for clean indentation, or check it with the HTML Validator.

Planning to put the file online? Download saves only the code you wrote, so a short snippet won’t have a <!doctype html> line or the viewport tag that phones need. Start with a full page from the HTML Starter Template and paste your code into its body.

Just want to look at an existing HTML file instead of writing one? Use the HTML Viewer.

Frequently Asked Questions

Is my code saved?

Yes, in this browser, as long as it allows site storage. Your last HTML, CSS and JS come back when you reopen the editor. Clearing your browser data removes them, and opening a shared project replaces them, so download anything you want to keep.

Can I edit an HTML file I already have?

Yes. Click the open file button or drop the file on the editor, up to 5 MB. An .html file goes in the HTML tab, along with any CSS and JavaScript inside it. A .css or .js file goes in its own tab. Files on your computer that the page links to, like images/logo.png, won’t load. Download saves a new copy and leaves your original file alone.

Where do console.log messages go?

Open your browser’s developer tools (F12, or right-click and choose Inspect) and look at the Console tab. Messages from the preview show up there, along with any errors in your JavaScript.

Can I use Bootstrap, Tailwind or jQuery?

Sure. Add the library’s <link> or <script> tag from a CDN like jsDelivr or cdnjs at the top of the HTML tab. If Bootstrap’s styles override yours, paste a full page and put its <link> in the <head>. Your CSS tab is then added after it. Anything that needs localStorage or cookies may not work in the preview.

My page froze. What happened?

Usually a JavaScript loop that never ends, like while(true) {}. If the buttons still work, untick JavaScript, fix the loop, then tick it again. Refreshing may not help, because the editor runs your saved code when it opens. If it stays stuck, close the tab and clear this site’s data in your browser settings. That also deletes your saved code.

Why doesn’t localStorage work in the preview?

The preview is kept separate from this site, so code like localStorage.setItem("name", "Sam") throws an error. To test it, download the file and open it in your browser. Your click handlers and other page code still run here.

Do I need to write <html>, <head> and <body>?

No. Write just the bits you need in the HTML tab. Your CSS and JS are added to the page for you. If you paste a full document, the CSS goes into its <head> and the JS goes at the end of its <body>.

Can I share my code with someone?

Yes. Click Share, choose when the link should expire, then click Create link. It opens a copy of all three tabs, and anyone with the link can see your code. Shared code can be up to 1 MB, so download the file if yours is bigger. Sign in with Google if you want to see and delete your links later from your Dashboard.

Is it free?

Yes, and you don’t need an account. The preview runs in your browser, and your code is only sent to our server when you create a share link. If your code loads a library or calls another website, your browser contacts that site directly.

Share with a link

Anyone with the link can view it. It's not listed anywhere or shown in search engines.

By creating a link you agree to our Terms of Use.