Skip to content
    HTML
    1234
    CSS
    1234
    JS
    123
    Live preview
    Console
    >Console output will appear here...

    HTML Online Compiler and Live Editor for HTML, CSS and JavaScript

    This HTML online compiler gives you three panes for HTML, CSS and JavaScript and a live preview beside them. It works like any online HTML editor, except that the HTML live preview rebuilds half a second after you stop typing, and a console underneath shows console.log output and uncaught errors from your script. Use this HTML, CSS and JS editor to prototype a layout, test a CSS rule, debug a snippet or put together a small demo to share, straight from your browser with nothing to install.

    How to use the HTML online compiler

    1. Type markup in the HTML pane. Write only what belongs inside the body; the editor wraps it in a complete document for the preview.
    2. Add styles in the CSS pane and scripts in the JS pane. The CSS is placed in a style tag in the head and the JavaScript runs at the end of the body.
    3. Watch the preview update as you type, or click Run to rebuild it from scratch.
    4. Check the Console panel for logs and errors raised by your JavaScript.
    5. Use Templates or Library to start from an example or add a framework, then Share, Export or Preview (New Page) to take your work elsewhere.

    Features

    • Separate HTML, CSS and JavaScript panes with line numbers and resizable panels
    • HTML live preview that rebuilds 500 ms after you stop typing, plus a Run button to reload it
    • Console panel for console.log, info, warn and error, with line numbers for uncaught errors
    • Closing tags inserted automatically as you type in the HTML pane
    • 10 starter templates, including a responsive landing page, pricing table, login modal and to-do list
    • One-click tags for Tailwind CSS, Bootstrap 5 CSS, Font Awesome 6, Anime.js, Three.js and React 18
    • Import an .html file, export your work as a single HTML file, or open the preview in a new tab
    • Work auto-saves to local storage, and Share creates a link with all three panes encoded in the URL

    What works and what doesn’t

    • The panes are plain text areas without syntax highlighting, autocomplete or linting, and Format only adjusts indentation.
    • The JS pane is wrapped in a try block, so top-level let and const variables are not global and inline attributes such as onclick cannot see them.
    • import statements in the JS pane cause a syntax error. To use ES modules, add a script tag with type="module" in the HTML pane instead.
    • There is one pane each for HTML, CSS and JavaScript, so projects that need several files or a build step do not fit.
    • Shared links carry the code in the URL itself, so large pages produce very long links that some apps may shorten or cut off.
    • Saved work lives only in this browser's local storage. Clearing site data or switching device loses it unless you exported or shared it.

    Example programs

    Responsive card grid with CSS Grid

    Paste the markup into the HTML pane and the rules into the CSS pane, then drag the divider next to the preview to watch the columns wrap.

    <!-- HTML pane -->
    <div class="grid">
      <article>One</article>
      <article>Two</article>
      <article>Three</article>
    </div>
    
    /* CSS pane */
    .grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
      gap: 16px;
    }
    article {
      padding: 24px;
      border-radius: 8px;
      background: #e0e7ff;
    }
    

    Click counter with console output

    addEventListener keeps the handler in the JS pane, and each click also logs to the Console panel under the preview.

    <!-- HTML pane -->
    <button id="add">Clicked 0 times</button>
    
    // JS pane
    const button = document.getElementById('add');
    let clicks = 0;
    
    button.addEventListener('click', () => {
      clicks += 1;
      button.textContent = 'Clicked ' + clicks + ' times';
      console.log('click', clicks);
    });
    

    Dark mode toggle in the HTML live preview

    CSS custom properties hold the colours, and toggling one class on the root element switches every value that uses them.

    <!-- HTML pane -->
    <main>
      <h1>Theme demo</h1>
      <button id="toggle">Toggle dark mode</button>
    </main>
    
    /* CSS pane */
    :root { --bg: #ffffff; --fg: #111827; }
    :root.dark { --bg: #111827; --fg: #f9fafb; }
    body { background: var(--bg); color: var(--fg); }
    
    // JS pane
    document.getElementById('toggle').addEventListener('click', () => {
      document.documentElement.classList.toggle('dark');
    });
    

    Frequently asked questions

    Does HTML need a compiler?

    No. Browsers parse and render HTML and CSS directly, and they run JavaScript with a built-in engine that compiles it just in time, so there is no build step before a page works. Tools called an HTML compiler are really editors that render your code as you type, which is what the preview on this page does.

    Is this online HTML editor free to use?

    Yes. The editor, templates, console, import, export and share links are all free and need no account. Everything runs in your browser: the preview is built on your device and your code is saved to local storage rather than uploaded, so you can start working without signing up for anything.

    How does the HTML live preview work?

    The editor combines your HTML, CSS and JavaScript into one document and loads it into an iframe next to the panes. It rebuilds that document 500 milliseconds after you stop typing and clears the console each time. Click Run to force a full reload, for example to re-run code that only executes on page load.

    Can I use Tailwind CSS, Bootstrap or other libraries?

    Yes. The Library menu inserts a script or link tag for Tailwind CSS, Bootstrap 5 CSS, Font Awesome 6, Anime.js, Three.js or React 18 at the top of the HTML pane. You can also paste any other CDN tag yourself, because the preview loads external scripts and stylesheets like a normal web page does.

    Why can an onclick attribute not see a variable from my JavaScript?

    The JS pane is wrapped in a try block so that errors reach the console. That makes top-level let and const variables block-scoped instead of global, so inline attributes such as onclick cannot read them. Attach handlers with addEventListener in the JS pane, or assign the value to window, for example window.count = 0.

    How do I save or share my HTML, CSS and JavaScript?

    Your work auto-saves to this browser's local storage about a second after each change. To send it to someone, click Share for a link that encodes all three panes in the URL. To keep a file, click Export to download a single HTML page, and use Import to load an .html file back in.

    Can I start from a template?

    Yes. The Templates menu has 10 starting points: Responsive Landing, Modern Form, Grid Gallery, Glassmorphism, Flexbox Center, Login Modal, Pricing Table, JS Todo List, Neumorphic Calc, Countdown. Loading one replaces the code in all three panes, and if you have already written something the editor asks you to confirm first, so you do not lose work by accident.

    Embed this sandbox

    Paste this iframe into any web page and readers can run code without leaving it. The snippet travels in the URL, so there is nothing to host and no account to create. Open the sandbox, write your example, press Share, then append that link’s query string to the embed URL to preload it.

    <iframe src="https://webfiddle.xyz/embed/html" width="100%" height="480" loading="lazy"
            style="border:1px solid #ddd;border-radius:8px"
            title="WebFiddle html sandbox"></iframe>
    Preview the embed

    Related articles

    Related sandboxes

    Official documentation