HTML Formatter
Runs locally in your browser. Your input is not uploaded.Free, no sign-up
Input
Output
Format and minify HTML and check its basic structure.
How to use the HTML Formatter
- Paste HTML, or click Sample.
- Choose the indentation and line width. Inline CSS and JavaScript are formatted too.
- If the markup is broken, for example a closing tag that doesn't match, you'll see the problem and its line.
- Use Minify to shrink it for production. Copy or download the result.
Formatting without changing the page
In HTML, spaces between inline elements are visible: <b>a</b> <i>b</i> shows a gap that <b>a</b><i>b</i> doesn't. Keep rendering exact (the default) only adds line breaks where they can't show, which sometimes moves a tag's closing > to the next line. Tidier formats freely, which can add or remove a space next to inline elements.
What Minify does
- Collapses runs of whitespace to a single space, and removes comments (IE conditional comments stay).
- Removes whitespace only where it can never render, such as between
<meta>tags or table rows. - Leaves
<pre>,<textarea>,<script>and<style>content exactly as written.
Frequently asked questions
Which formatter is this?
Prettier, the formatter most web projects use, running in your browser. The output matches what npx prettier gives with the same options.
Is my HTML uploaded or run?
No. It's parsed and printed in your browser; scripts in it are never executed.
Related tools
All tools- CSS Formatter / MinifierFormat CSS, SCSS and Less, or minify CSS stylesheets.
- JavaScript Formatter / MinifierFormat JavaScript, JSX and TypeScript, or minify JavaScript, without executing it.
- Markdown PreviewerWrite Markdown with a live, XSS-safe preview, block tracking images, and export to HTML.
- XML FormatterFormat, validate and minify XML with syntax highlighting, entirely in your browser.
- Regex TesterTest regular expressions with live match highlighting, capture groups, flags and explanations.