HTML Formatter: Beautify and Indent HTML Code
Turn one-line or messy HTML into neatly indented code that is easy to read and edit.
- Works on your device. Nothing is uploaded.
- Free, no watermark
- No signup
How to use
- Paste HTML or open an .html file.
- Pick the indent: 2 spaces, 4 spaces or tab.
- Copy the formatted code or download it.
Good to know
The formatter puts each block element (div, ul, li, table and so on) on its own line and indents children one level deeper. Inline elements like <b> and <a> stay inside their text so the page looks the same. It uses js-beautify, a widely used open-source formatter (MIT licence).
Content of <pre> and <textarea> is kept exactly, because spaces there are visible on the page. CSS inside <style> and JavaScript inside <script> are formatted too.
Formatting only changes spaces and line breaks, never your tags or text. It does not fix broken HTML: an unclosed tag stays unclosed. Use the HTML viewer to check how the page looks.
Questions
Will formatting change how my page looks?
Normally no. Only whitespace between block elements changes; inline text and <pre> blocks are kept.
2 spaces or 4 spaces?
Both are common. Many web projects use 2 spaces; pick what your team uses.
Can it format minified HTML?
Yes, that is its main use.
Does it check for errors?
No. It formats what you give it. Use a validator to check HTML rules.
Is my code sent to a server?
No. It runs in your browser.