Home › Developer Tools › HTML Editor (Live Preview)

HTML Editor (Live Preview)

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.

Last updated:

HTML
CSS
JS
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)

  1. 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.
  2. Watch the preview update as you type. Turn off Auto-run if your script is heavy and click Run instead (or press Ctrl+Enter).
  3. Check the console under the preview for console.log output and error messages with line numbers.
  4. Change the layout to side-by-side or stacked, and switch the preview width to test phone and tablet sizes.
  5. 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

KeysAction
Ctrl + Enter (⌘ + Enter on Mac)Run the code now
Tab / Shift + TabIndent / outdent the line or selected lines
Esc, then TabMove keyboard focus out of the editor
EnterNew line that keeps the current indentation (and adds one level after { or an opening tag)
> at the end of an opening tagAdds 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.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

HTML FormatterBeautify and indent HTML code with a live preview.HTML MinifierMinify HTML: strip comments and whitespace safely and see how many bytes you save.CSS FormatterBeautify CSS with indent controls and optional property sorting.Markdown EditorWrite Markdown with a toolbar, live split preview, autosave and .md or HTML export.Cookie Consent Banner GeneratorDesign a cookie banner with accept, reject and settings buttons and copy the HTML/CSS/JS.CSS Media Query GeneratorBuild @media rules for widths, orientation, dark mode and hover, or get framework breakpoints.CSS Scrollbar GeneratorStyle scrollbars: width, colors, radius and hover, with ::-webkit-scrollbar and scrollbar-color CSS.CSS Toggle Switch GeneratorDesign pure-CSS toggle switches: size, colors, shape and animation. Copy accessible HTML + CSS.Open Graph PreviewPaste OG tags and preview how links look on Facebook, X and LinkedIn.YouTube Embed Code GeneratorCreate responsive YouTube embed code with start time, autoplay, loop and privacy mode.CSS Box Shadow GeneratorDesign layered CSS box shadows with a live preview, presets and one-click Copy CSS.CSS Border Radius GeneratorRound each corner, draw elliptical 8-value radii or random blob shapes and copy the CSS.CSS Button GeneratorDesign CSS buttons with gradients, borders, shadows and hover and active states, then copy the code.CSS Flexbox GeneratorBuild flexbox layouts visually: set container and item properties, then copy the CSS and HTML.Twitter Card GeneratorCreate X / Twitter Card meta tags with Open Graph fallbacks, character counters and a live preview.CSS Grid GeneratorDraw CSS grid layouts: set tracks and gaps, drag to name areas, then copy the CSS and HTML.PX to REM ConverterConvert px to rem or em and back, with a 1-100px table and a whole-CSS converter.Glassmorphism CSS GeneratorDesign frosted-glass UI cards with blur, transparency and border sliders, then copy the CSS.CSS Text Shadow GeneratorLayer CSS text shadows with a live preview and neon, 3D, outline and retro presets.CSS Clip-Path GeneratorDraw CSS clip-path shapes by dragging points: polygons, circle, ellipse and inset. Copy the CSS.CSS Animation GeneratorCreate CSS keyframe animations from 23 presets with live preview, timing controls and Copy CSS.CSS Triangle GeneratorMake CSS triangles in 8 directions with the border trick or clip-path. Set size and color, copy CSS.CSS Loader GeneratorPick from 14 pure CSS spinners and loaders, set color, size and speed, then copy the HTML and CSS.Cubic Bezier GeneratorDrag the control points to design a CSS easing curve, compare it with linear and copy cubic-bezier().CSS Filter GeneratorAdjust blur, brightness, contrast, hue, sepia and drop-shadow on an image and copy the CSS filter.CSS Specificity CalculatorCalculate CSS selector specificity (a, b, c), including :is(), :not(), :has() and :where(), and compare.Neumorphism CSS GeneratorDesign soft UI neumorphic shapes with live preview and copy the box-shadow CSS.SVG Wave GeneratorMake layered SVG waves for section dividers and export SVG, PNG or a CSS background.SVG Blob GeneratorGenerate random organic SVG blob shapes with gradients and export SVG, PNG or CSS clip-path.CSS Clamp GeneratorTurn min/max sizes and viewport widths into a fluid CSS clamp() value in rem and vw.CSS @font-face GeneratorTurn font files or URLs into ready-to-paste @font-face rules with weights, styles and a preview.CSS Sprite GeneratorPack many icons into one sprite sheet PNG and get CSS classes with background-position.CSS Text Gradient GeneratorMake gradient text with background-clip:text: color stops, angle, font preview and fallback CSS.HTML Form BuilderDrag and drop form fields with labels and validation, then copy accessible HTML and CSS code.Iframe GeneratorCreate iframe embed code: size or responsive ratio, border, allow, sandbox, lazy load, live preview.PX to VW ConverterConvert pixels to vw and vh for any viewport size, and vw/vh back to px, with breakpoint tables.SVG Path EditorEdit an SVG path d attribute visually: drag points, edit commands, convert, scale and minify.SVG to CSS Data URITurn SVG code into a small URL-encoded data URI for CSS backgrounds, with Base64 size comparison.CSS Background Pattern GeneratorMake pure-CSS stripes, dots, checkerboard, zigzag and grid backgrounds and copy the code.CSS Color Filter GeneratorTurn a HEX color into a CSS filter that recolors black icons and SVGs, with an accuracy score.CSS Gradient Animation GeneratorCreate animated gradient backgrounds: pick colors, angle and speed, preview live and copy the CSS.CSS Hover Effects GeneratorPick button, link and image hover effects, tweak colors and timing, and copy the HTML and CSS.CSS InlinerMove CSS from style blocks into inline style attributes so HTML emails render in every client.CSS Shape Divider GeneratorCreate wave, tilt, curve and triangle section dividers and copy the SVG, HTML and CSS.CSS Transform GeneratorRotate, scale, skew and translate an element with sliders and copy the CSS transform code.Font Pairing ToolPreview Google Font heading and body pairs on real layouts and copy the embed code and CSS.HTML Accessibility CheckerPaste HTML to find WCAG accessibility problems with impact level, the failing element and a fix.HTML Image Map GeneratorDraw clickable rectangle, circle and polygon hotspots on an image and get image map HTML.SVG ViewerOpen or paste SVG code to preview it live with zoom, backgrounds, size info and PNG export.Pathfinding VisualizerAnimate BFS, DFS, Dijkstra, A* and greedy search on a grid with walls, weights and mazes.SVG to JSXTurn SVG code into a clean React component: camelCase attributes, style objects, TypeScript.Tailwind CSS Cheat SheetSearchable Tailwind class to CSS reference with live previews, class decoder and color palette.Web App Manifest GeneratorCreate a PWA manifest.json and every app icon size from one image, downloaded as a ZIP.
See all 52 Web, HTML & CSS Tools →