HTML Formatter & Beautifier
Format and beautify messy or minified HTML — re-indent nested tags by depth, keep attributes intact, and leave <pre>, <script>, <style> and <textarea> contents untouched. Runs entirely in your browser.
Input
Settings
Output
Guides
Paste in minified, machine-generated, or just messily-indented HTML and get it back cleanly re-indented — one nesting level per line, attributes untouched, and the tags that actually shouldn't be reformatted left completely alone. Useful for reading a minified page's source, cleaning up markup pasted from a WYSIWYG editor, or tidying a template before you commit it.
How to use it
- Paste your HTML into the input box, or upload an
.html/.htmfile. - Pick your indentation: 2 spaces, 4 spaces, or a tab.
- Optionally turn on Preserve existing blank lines (keeps intentional spacing between sections) or Remove HTML comments (strips everything wrapped in
<!-- -->). - Copy the result or download it as
formatted.html.
Formatting happens as you type — there's no button to press.
How it decides what goes on one line
A tag whose entire content is text, or text mixed with inline elements like <a>, <span>, <strong>, <em> or <img>, stays on a single line — <li>Item 1</li> and <p>Hello <strong>world</strong>!</p> don't get exploded across five lines just because there's a nested tag in there. A tag that contains block-level children (<div>, <ul>, <section>, and the like) breaks: the opening tag, each child, and the closing tag each get their own line, indented one level deeper than their parent.
Void elements — <br>, <hr>, <img>, <input>, <meta>, <link>, <area>, <base>, <col>, <embed>, <source>, <track>, <wbr> — never get a closing tag or a false indentation level for "children" they can't have. Self-closing syntax (<img />) is preserved exactly as written.
What it never touches
<pre>,<script>,<style>and<textarea>contents are reproduced byte-for-byte. Whitespace inside these is part of what renders or executes — reformatting a<pre>block changes the text it displays, and re-indenting a<script>body can change behavior if it contains a template literal or an indentation-sensitive string. The tool re-indents the opening tag and leaves everything between it and the matching closing tag exactly as you wrote it.- Attributes are never reordered, rewritten, or reformatted. Whatever quoting and spacing your tag used stays exactly as-is; only the tag's position and indentation change.
- Malformed HTML doesn't crash the formatter. An unmatched closing tag is dropped rather than corrupting the rest of the output, so pasting a fragment (not a full document) works fine.
Why doesn't it fix unclosed tags or validate my markup?
It's a formatter, not a validator — it re-indents the structure it can parse and leaves genuinely broken markup as close to your original intent as it reasonably can. If you need to check for missing tags, mismatched nesting or invalid attributes, run the result through an HTML validator afterward.
Does it minify or strip anything?
No — indentation is added, not removed, and no tags, attributes or text are deleted (comments are only removed if you turn that option on). If you're looking to shrink a page's byte size instead, use the HTML Minifier.
Is my HTML uploaded anywhere?
No. The formatter runs entirely in your browser — your markup is never sent to a server, logged, or stored, and uploading a file just reads it locally in the page. It works offline.