HTML Beautifier
Format HTML documents, including inline CSS and JavaScript.
HTML Beautifier – HTML Formatter and Pretty Printer
Minified HTML, markup generated by a CMS, or a template pasted from an email builder can be impossible to read. The HTML beautifier formats it into properly indented markup with one element per line where it makes sense. Because it uses Prettier, it also formats the CSS inside <style> tags and the JavaScript inside <script> tags.
How to format HTML
- Paste your HTML or open an
.htmlfile. The Sample button loads a full page written on one line. - Pick indentation and line width.
- Choose how whitespace is treated (see below) and whether the closing
>of a tag with many attributes stays on the last attribute line. - Copy or download the formatted HTML.
Whitespace sensitivity
In HTML, whitespace between inline elements such as <a>, <span>, and <strong> is visible on the page. A careless formatter can add or remove spaces and change how text looks. Prettier offers three modes:
- Respect CSS display (default) – whitespace is only changed around block elements like
<div>and<p>, never inside inline content. - Strict – all whitespace is treated as significant; the output may look a bit unusual but is guaranteed to render identically.
- Ignore – maximum readability; whitespace may be changed everywhere.
What else is formatted
Long attribute lists are split one attribute per line, void elements are normalized, and embedded <style> and <script> blocks are formatted with the CSS and JavaScript formatters. Comments and <pre> contents are preserved.
Related HTML tools
Before deploying, compress the page with the HTML Minifier. For Angular templates use the Angular Formatter, for SVG markup the SVG Formatter, and for strict XML documents the XML Beautifier.
Frequently Asked Questions
Does it format CSS and JavaScript inside the HTML?
Yes. Contents of <style> tags are formatted as CSS and contents of <script> tags as JavaScript, using the same rules as the CSS and JavaScript beautifiers.
Can it fix broken HTML?
It is tolerant of many common mistakes, but badly unbalanced tags produce an error with the line and column. Fix the reported tag and format again.
Why did my text get extra spaces or line breaks?
Choose the Strict whitespace mode. It treats every space as significant so the rendered text is guaranteed to stay the same.
Is the HTML uploaded?
No. Formatting happens entirely in your browser.