HTML Formatter
Beautify HTML code with proper indentation and formatting.
Format messy or minified HTML so it's easy to read: each element on its own line, nested tags indented and attributes kept as written. Choose 2 spaces, 4 spaces or tabs. Code inside script and style tags is formatted too, and whitespace in pre and textarea elements is left alone so the page looks the same. The formatter uses the open-source js-beautify library in your browser; it changes only layout, never your content.
Common use cases
- Read the HTML of a page copied from a browser's source view
- Tidy an email template before editing it
- Make generated HTML readable before a code review
- Clean up HTML pasted from a CMS or website builder
How to use
- Paste your HTML, or press Try an example.
- Choose the indent.
- Copy or download the formatted HTML.
FAQ
Will it fix broken HTML?
No: it formats what's there. Use the HTML validator to find unclosed tags, duplicate ids and missing alt text.
Can formatting change how the page looks?
Rarely. Extra whitespace between inline elements can add a small gap; content in pre and textarea is never touched.
How do I make HTML smaller instead?
Use the HTML minifier, which removes comments and unneeded whitespace.
Related tools
- HTML MinifierMinify HTML code by removing unnecessary whitespace.
- CSS MinifierMinify CSS code by removing whitespace and comments.
- XML FormatterFormat and indent XML documents for better readability.
- SQL FormatterFormat and beautify SQL queries with proper indentation.
- JSON FormatterFormat, validate, and beautify JSON data with syntax highlighting.
- JS MinifierMinify JavaScript code to reduce file size.
- HTML Entity ReferenceIn Reference