Online HTML Editor - Write, Preview and Clean Up Markup in Your Browser
An online HTML editor removes the ceremony from testing a piece of markup. Instead of creating a file, saving it, starting a local server and switching to a browser, you paste a snippet on the left and watch it render on the right. This editor pairs a line-numbered code surface with a sandboxed live preview, a visual WYSIWYG mode, and a set of transformations - beautify, minify, sanitize, strip tags and entity escaping - that turn messy real-world markup into something you can actually ship.
How the live preview works
Your document is assembled into a complete HTML page - doctype, <head>, your inline CSS, your markup - and handed to an <iframe> through the srcdoc attribute. Rendering restarts roughly 300 ms after you stop typing, which is long enough to keep typing smooth on a large document and short enough to feel instant. The frame is sandboxed, so the previewed page has no route back into the editor.
allow-same-origin. A frame that holds both allow-same-origin and allow-scripts can reach straight into the page that embeds it, which makes the sandbox decorative. Turning on Allow scripts adds allow-scripts and nothing else.Beautify, minify and the difference between them
Beautifying re-indents machine-generated or minified markup into readable, correctly nested HTML at the indent style, indent size and wrap length you choose. It only moves whitespace: comments, attributes and text survive untouched. Minifying goes the other way, collapsing whitespace a browser would not paint, dropping comments, collapsing boolean attributes and optionally removing attribute quotes, then reporting the saving as both bytes and a percentage. Whitespace inside <pre>, <textarea>, <script> and <style> is byte-significant and is never collapsed.
Cleaning markup pasted from Word or Google Docs
Content pasted out of a word processor arrives wrapped in class="MsoNormal", <o:p> tags, inline style declarations and <font> elements. The Sanitize pass rebuilds the document from a whitelist of semantic tags - headings, paragraphs, lists, links, tables, emphasis - rewrites <b> to <strong> and <i> to <em>, and keeps only the href, src, alt and title attributes. Anything that is not on the list is unwrapped rather than deleted, so no text is ever lost.
< and & into entities so a snippet can be displayed as code. Sanitising removes the parts of a document that are unsafe or meaningless. Escaping a hostile string makes it printable; it does not make it safe to re-insert as markup, and sanitising is what you want before storing user content.What the statistics and diagnostics tell you
Every count comes from a real tokenizer rather than a regular expression, so a <div> written inside a JavaScript string is not miscounted as an element. Byte size is measured with UTF-8 encoding, which is why an emoji costs four bytes rather than one character. The nesting depth readout is a good early warning: markup nested past ten levels is usually a sign of wrapper <div> soup that will make CSS specificity painful later, and the tag frequency chart makes the same point visually - a document that is 60% <div> is not a semantic document.
The diagnostics panel is advisory and never blocks anything. It reports unclosed tags with the line where they opened, deprecated elements such as <center> and <font> with the CSS property to reach for instead, and accessibility hints: images with no alt, form controls with no label, a missing lang, empty headings and heading levels that jump from h1 straight to h4.
Block, inline and void elements
Three distinctions explain most surprises in the preview. Block elements - div, p, section, li - start on a new line and fill the available width. Inline elements - span, a, strong - flow inside a line, which is why two adjacent inline elements with no whitespace between them render as one unbroken word. Void elements - br, img, hr, input, meta - never take a closing tag, and writing one is a parse error the browser silently recovers from.
Privacy
Parsing, rendering, formatting and every export happen inside your own browser tab. Nothing is uploaded, logged or transmitted, which matters for HTML in particular: page source routinely carries staging URLs, customer names inside a rendered table, unreleased copy and API keys tucked into data- attributes.