HTML Formatter & Beautifier Online
- This tool runs entirely in your browser. Nothing you enter or upload is sent to a server.
HTML
Formatted HTML
Result appears here.About this tool
Paste minified or badly indented HTML and get clean, consistently indented markup using Prettier — the same formatter most front-end teams run in their editors. Inline <style> and <script> blocks are formatted too, using the CSS and JavaScript rules.
Minify mode strips comments and whitespace between tags while leaving <pre>, <textarea>, <script> and <style> contents untouched. Conditional comments such as <!--[if IE]> are kept. This is a conservative minifier: it does not rename classes or shorten attributes.
To use it, paste markup or press Sample, choose Beautify or Minify, and for Beautify pick 2 spaces, 4 spaces or tabs. A line such as <ul><li>Fast</li><li>Private</li></ul> comes out with the <ul> on its own line and each <li> indented beneath it. Copy the result or download it as index.html. Fragments work as well as full documents, so you can format a snippet from a CMS or an email template.
Whitespace is the main pitfall. Prettier follows CSS whitespace rules, so inline elements such as <a>, <span> and <b> are not split onto new lines in a way that would add visible gaps. Sometimes that leaves a long line or an awkward-looking tag break; that is deliberate, because the alternative would change how the page renders. Lines wrap at 100 columns.
Formatting runs locally; the Prettier engine loads only on this page.
Frequently asked questions
Will formatting change how my page looks?
Prettier respects CSS whitespace rules for inline elements, so rendering stays the same in almost all cases.
Does it fix invalid HTML?
It formats what it can parse. Severely broken markup produces an error message pointing at the problem. It will not add missing closing tags or correct nesting for you.
Can I format Vue or JSX here?
This tool is for HTML documents and fragments. JSX and Vue single-file components need their own parsers; for JSX use the JavaScript formatter.
Does minifying remove everything it can?
No. It removes comments and the whitespace between tags and collapses runs of spaces, but protects <pre>, <textarea>, <script> and <style> blocks. Scripts and styles are not minified themselves.
Why are my inline scripts and styles reformatted?
Beautify mode formats embedded <script> and <style> blocks as JavaScript and CSS, so the whole document comes out consistent. Use Minify if you want those blocks left exactly as they are.
Is my markup uploaded?
No. Everything is processed in your browser.