HTML Formatter
Turn minified or messy HTML into clean, consistently indented markup. Choose 2 spaces, 4 spaces or tabs, set a wrap length and decide whether to keep blank lines; embedded CSS and JavaScript are formatted as well. Formatting is powered by the widely used js-beautify library and runs entirely in your browser.
How to use the HTML Formatter
- Paste your HTML or press Load example.
- Pick the indent size and an optional wrap line length.
- Choose whether to keep blank lines and end with a newline.
- Press Format HTML, then copy or download the result.
Features
- Indentation with 2 or 4 spaces or tabs
- Optional line wrapping at a set column
- Formats inline <style> and <script> content
- Preserves or removes blank lines
- Download as an .html file
Benefits
- Make template and email HTML readable before editing
- Get consistent formatting for code reviews
- No sign-up and no upload of your markup
Frequently asked questions
Will formatting break my page?
Formatting only changes whitespace between tags. Content inside <pre> and <textarea> is left alone, but whitespace-sensitive inline layouts can shift slightly, so review the result.
Does it fix invalid HTML?
No. It re-indents the markup as written. Missing closing tags are not added, so the indentation may look uneven around errors.
What does wrap line length 0 mean?
Zero turns wrapping off, so long lines are kept on one line.
Related tools
- JSON Formatter — Beautify or minify JSON with 2-space, 4-space or tab indents, sort keys and browse it as a collapsible tree.
- JSON Validator — Check JSON syntax as you type, see the exact line and column of any error and get warnings for duplicate keys.
- XML Formatter — Pretty-print or minify XML with comments, CDATA and DOCTYPE support, plus a well-formedness check with error positions.
- CSS Formatter — Beautify minified CSS into readable rules with custom indentation, brace style and one selector per line.
- JavaScript Formatter — Beautify JavaScript with configurable indentation, brace style and line wrapping to make minified code readable.
- Code Minifier — Minify JavaScript with Terser, plus CSS and HTML, and see the original size, minified size and percentage saved.