Write HTML, CSS and JavaScript in separate panes and watch the page update as you type. Your code runs in a sandboxed frame, console messages appear below it, and your work is saved in this browser automatically.
HTML
1
CSS
1
JS
1
Preview
Console output from your code appears here.
Tip: Ctrl+Enter runs the code. In the editor, Tab indents; press Esc then Tab to move focus out. Your code is saved in this browser automatically.
Advertisement
Advertisement
How to use the HTML Editor (Live Preview)
Type your HTML in the HTML pane. Add styles in the CSS pane and scripts in the JS pane: they are combined into one page.
Watch the preview update as you type. Turn off Auto-run if your script is heavy and click Run instead (or press Ctrl+Enter).
Check the console under the preview for console.log output and error messages with line numbers.
Change the layout to side-by-side or stacked, and switch the preview width to test phone and tablet sizes.
Download the page as a single .html file. Your code is also saved automatically in this browser.
How the live preview is built
When you type, the three panes are combined into one HTML document. If the HTML pane holds only a fragment (for example a few <div> elements), it is placed inside a standard page with <!DOCTYPE html>, a UTF-8 charset and a mobile viewport tag. Your CSS goes into a <style> element in the head, and your JavaScript into a <script> element at the end of the body, so the DOM is ready when the script runs. If you paste a complete document, the CSS and JS are inserted before </head> and </body>.
The result is shown in an iframe with the sandbox attribute and without allow-same-origin. That gives the preview a unique, opaque origin: scripts run, but they cannot read this page, its cookies or its local storage. A side effect is that localStorage and document.cookie throw errors inside the preview.
Keyboard shortcuts
Keys
Action
Ctrl + Enter (⌘ + Enter on Mac)
Run the code now
Tab / Shift + Tab
Indent / outdent the line or selected lines
Esc, then Tab
Move keyboard focus out of the editor
Enter
New line that keeps the current indentation (and adds one level after { or an opening tag)
> at the end of an opening tag
Adds the matching closing tag in the HTML pane
Tips for testing HTML, CSS and JavaScript
Use the Phone and Tablet widths to check media queries at 375 px and 768 px without resizing your window.
Load libraries from a CDN with a full URL, for example a script tag whose src starts with https://cdn.jsdelivr.net/ in the HTML pane. Relative file paths do not work because there is no project folder.
Turn off Auto-run when writing loops or timers, so a half-typed while loop cannot freeze the preview. Click Run when you are ready.
Read errors in the console: the line number refers to your JS pane, so you can jump straight to the problem.
Frequently asked questions
Is this HTML editor free?
Yes. It is completely free with no sign-up. Everything runs in your browser.
Is my code uploaded anywhere?
No. The preview is built locally from your code and shown in a sandboxed iframe. Auto-save uses your browser's local storage, so the code stays on this device.
Is it safe to run JavaScript here?
The preview runs in a sandboxed iframe without access to this page, its storage or cookies. Scripts can still make network requests or open pop-ups like any web page, so only run code you trust.
Why does my external script or font not load?
Links to CDNs and Google Fonts work when you are online. Relative paths such as images/logo.png do not, because the page has no folder of files: use full https:// URLs or data URIs instead.
How do I see errors in my JavaScript?
Open the Console panel under the preview. It shows console.log, console.warn and console.error messages and uncaught errors with their line numbers in the JS pane.
Can I edit a full HTML document?
Yes. If the HTML pane contains a complete document with <html> or <body>, your CSS is inserted before </head> and your JavaScript before </body>. Otherwise the HTML is placed inside a standard page.
Will my work be lost if I close the tab?
No. Your code is auto-saved in this browser and restored when you come back. Clearing your browsing data removes it, so download important work as an .html file.