HTML Formatter
Paste HTML and get it back neatly indented, ready to read, review or paste into a template. The formatting runs in your browser, so the code never leaves your device, and it is only re-spaced as text: nothing in it is run.
Free, no sign-up. Your code stays in your browser.
Your HTML
Paste HTML and press Format.
How to
Format HTML in three steps
Paste your HTML
Drop in a whole page or a fragment. Minified markup, a single long line and inconsistent indentation are all fine.
Choose the layout
Pick spaces or tabs, an optional line length and whether to keep blank lines.
Format, copy or download
Press Format, then copy the result or download it as a file.
What to know before you format
- Whitespace can matter in HTML. Formatting changes spaces between tags, which can slightly change how inline elements such as links and buttons sit next to each other. Check the page after you format it.
- Text inside pre and textarea is left as it is, and the contents of script and style blocks are formatted as JavaScript and CSS.
- The formatter does not fix mistakes. Unclosed or misnested tags are re-indented as written, so use a validator to find them.
- For very large files, split the markup into parts: the limit is 300,000 characters.
FAQ
HTML formatter questions
Is my HTML uploaded anywhere?
No. The formatter runs in your browser and the page makes no network request with your code. Closing the tab clears it.
Will formatting change how my page looks?
Usually not, but it can. Adding or removing whitespace between inline elements such as links, spans and buttons can change the small gaps between them. Text in pre and textarea is kept as it is. Check the page after formatting if spacing matters.
Does it fix broken HTML?
No. It re-spaces what you give it. Missing closing tags or wrongly nested elements stay as they are, so the indentation may look odd where the structure is wrong, which can help you spot the problem.
Does it format the CSS and JavaScript inside the page?
Yes. Style and script blocks are formatted too. Scripts are only re-spaced as text and are never run.
Is there a size limit?
Yes: 300,000 characters. If your file is longer you get a message saying so. Split it into parts and format each part.
Can I minify HTML here?
Not on this page. This tool only makes HTML easier to read. An HTML minifier is not available yet.