FormatterHQ

Online HTML Editor with Live Preview

Write new markup or repair an existing file in this online HTML editor. Tags autocomplete, closing tags are inserted for you, and the preview re-renders shortly after you stop typing.

Input HTML
Output HTML
Ready.

How to use the Online HTML Editor

  1. Open an .html or .htm file, drop one onto the input panel, or start from the sample.
  2. Write or change the markup; tag names and attributes autocomplete and closing tags are added for you.
  3. Check the rendered result in the preview, which refreshes about 350 ms after you pause.
  4. Untick Auto update while you edit scripts, then press Run or Ctrl/⌘ + Enter to refresh on demand.
  5. Use Copy or Download to take the finished markup back to your project.

When to use the online HTML editor

This online HTML editor is meant for producing markup: drafting a component before it goes into a template, adjusting an email layout, rebuilding a landing page section or correcting a broken file. It runs the same editor and sandboxed renderer as the HTML Viewer. If you only want to see what an existing file or snippet looks like, open it there; if you plan to write or change the code, the workflow below is the one to follow.

What the editor does while you type

  • Syntax highlighting for HTML, including CSS inside <style> and JavaScript inside <script>.
  • Autocompletion of tag and attribute names, plus automatic closing tags when you finish an opening tag.
  • Bracket matching, code folding and undo history, with Ctrl/⌘ + F to search and Tab to indent.
  • A line and character count in the input panel header.
  • Layout and fullscreen buttons: switch between side-by-side and stacked panels on wide screens, or expand the preview to check a section at a larger size.

Building a snippet or page section

Components are easier to get right in isolation. Paste only the part you are working on, wrap it in the smallest document that gives it the right context, and add a temporary rule that outlines every box:

<style>
  * { outline: 1px solid rgba(220, 38, 38, .35); }
  .plan { max-width: 18rem; padding: 1.25rem; border: 1px solid #ddd; }
</style>
<section class="plan">
  <h2>Team</h2>
  <p><strong>$12</strong> per user / month</p>
  <ul><li>Shared folders</li><li>Priority support</li></ul>
  <a href="#">Choose plan</a>
</section>

The outlines reveal unexpected margins, elements that overflow their parent and wrappers you forgot to close. Delete the rule before you copy the snippet back into your project. Testing structure this way also shows whether headings and lists nest the way you intended, which matters for screen readers as much as for looks.

Editing HTML email markup

Email layouts are usually tables with inline styles and a fixed width of around 600 pixels, because many mail programs ignore stylesheets and modern layout properties. The editor lets you adjust cell padding, colours and alignment and see the effect straight away. Keep two limits in mind: the preview is a web browser, so it shows how a standards-based engine draws the message rather than how a particular mail program will, and images must use absolute URLs. Send a real test message before any campaign goes out.

How the preview is sandboxed and when it updates

Your markup is placed in an <iframe> through its srcdoc attribute, with the sandbox flags allow-scripts, allow-forms, allow-popups and allow-modals. Same-origin access is not granted, which has practical consequences:

  • Scripts run, and alert() or confirm() dialogs work, but the code cannot reach this website, its cookies or its storage.
  • localStorage, sessionStorage and document.cookie are unavailable and throw errors.
  • Relative URLs resolve against this site's address instead of your project folder, so local images and stylesheets do not load.

With Auto update ticked, the preview is rebuilt about 350 milliseconds after your last keystroke, or about 900 milliseconds when the document is longer than 200,000 characters. Each rebuild replaces the whole document, so scripts start again and form input is lost. When you are writing JavaScript that needs to keep state, untick Auto update and refresh with the Run button or Ctrl/⌘ + Enter.

Finishing and exporting your markup

Copy puts the source on your clipboard. Download saves it as html-editor.html; rename it, for example to index.html, before publishing. Save & Share stores the code and gives you a link. When someone opens a shared link, the code appears in the editor but is not rendered until they press Run, so nobody runs another person's scripts by accident.

Before the markup leaves the editor, tidy the indentation with the HTML Formatter, check for unclosed or misnested tags with the HTML Validator, and compress the final version with the HTML Minifier if file size matters.

Frequently asked questions

Is this the same tool as the HTML Viewer?
Yes. Both pages use the same code editor and the same sandboxed preview. The HTML Viewer is described for inspecting markup you already have; this page covers writing and revising it.
Why does the preview flicker or lose what I typed into a form?
Every refresh replaces the whole preview document, so scripts start again and form fields, scroll position and variables reset. Untick Auto update and refresh manually when you need the state to stay put.
Can scripts in the preview use localStorage or cookies?
No. The preview frame is sandboxed without same-origin access, so it has an opaque origin and storage APIs throw a SecurityError. Guard such code with try/catch or test it on a local web server.
Why do my images and stylesheets not load?
Relative paths such as images/logo.png are resolved against this website's address, not your project folder, so the files are not found. Use absolute https URLs while editing.
Is my HTML sent anywhere?
Rendering happens in your browser. The code is stored on the server only if you press Save & Share to create a link.

Last updated October 3, 2026

Related tools

Real-Time HTML Editor A real-time HTML playground for learning: edit HTML, CSS and JavaScript and watch the result update as you type. CSV Editor Online Edit CSV files online like a spreadsheet: change cells, add, move or delete rows and columns, sort, filter, find and replace, undo, then export. JSON Editor Edit JSON online with a live tree preview, instant validation and one-click formatting, repair and minification. Online Markdown Editor Write Markdown with a live side-by-side preview and the generated HTML source. Free online Markdown editor, no sign-up. Mermaid Live Editor Write Mermaid flowcharts, sequence, class, ER, Gantt and state diagrams with a live preview, then export SVG or PNG. Online Code Editor Multi-language online code editor with syntax highlighting for 30+ languages. Open, edit, save and download code files. HTML Viewer Paste HTML or open a file and see it rendered instantly in a safe, sandboxed live preview. Free online HTML viewer. LaTeX Math Renderer Render LaTeX math equations with KaTeX in a live preview and copy the MathML or HTML to use in web pages. Line Graph Maker Create line graphs online from CSV or JSON data. Multiple series, axis labels, custom colours and free SVG download. MP3 & Audio Metadata Viewer Read the ID3 tags and metadata of MP3, FLAC, M4A, Ogg, WAV and other audio files: title, artist, album, cover art, bitrate and duration. Word, Excel & PowerPoint Metadata Remover Remove author, last editor, company, editing time, custom properties and reviewer names from Word, Excel and PowerPoint files. No upload. Word, Excel & PowerPoint Metadata Viewer See the hidden metadata in .docx, .xlsx and .pptx files: author, last editor, editing time, comment authors, tracked changes and more.