HTML Cleaner
WM-87Paste HTML and remove the extra spaces, blank lines and comments, strip every tag to get plain text, or switch to Beautify or Minify. Pre, textarea, script and style content is left alone.
Runs in your browser. Nothing is uploaded.
HTML
Cleaned HTML
How to use it
- Paste your HTML into the input box.
- Choose what to clean: comments, runs of spaces, trailing spaces, blank lines, or joining everything on one line.
- Press Clean HTML. Press Remove all tags for the visible text, Beautify to indent it, or Minify to shrink it.
- Copy the result or download it.
What Clean HTML changes
Clean HTML touches only whitespace and comments. Tags, attributes and text stay as they are. Runs of spaces and tabs become one space, spaces at the ends of lines are trimmed, and blank lines are removed or limited to one, depending on your choice. Conditional comments such as the Internet Explorer ones are kept even when comment removal is on, because they carry instructions. An unclosed comment stops the tool with a line number instead of deleting the rest of the page.
Content that is never touched
Whitespace matters inside pre and textarea elements, and script and style blocks may contain code that depends on line breaks, so their content is copied through exactly as written. Only the text outside those blocks is cleaned. Joining everything on one line also leaves those blocks intact. Collapsing spaces elsewhere does not change what a browser shows, because browsers already collapse runs of spaces in normal text.
Remove tags, beautify and minify
Remove all tags returns the visible text: script and style blocks and comments are dropped with their content, block-level tags such as p, div and li become line breaks, and HTML entities such as & are left as written. Beautify indents the markup and Minify removes comments and extra whitespace; both use the same engines as the HTML Formatter and HTML Minifier tools. Use the formatter when you also need to wrap long lines or reformat embedded code.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Paste the HTML to clean. | The input box is empty or holds only whitespace. | Paste the HTML you want to clean. |
Questions people ask
How do I remove extra spaces and blank lines from HTML?
Paste the HTML, keep Collapse runs of spaces and Trim each line ticked, set Empty lines to Remove all, and press Clean HTML. Tags and attributes are not changed, only whitespace and comments.
Will cleaning HTML change how the page looks?
Normally not, since browsers already collapse repeated spaces in ordinary text. Content inside pre, textarea, script and style is left exactly as written, so preformatted text and code keep their spacing.
How do I strip all HTML tags and keep the text?
Press Remove all tags. It drops script and style blocks and comments, turns block tags into line breaks and removes every other tag. Entities such as & stay as they are, so decode them separately if you need plain characters.
Does it remove HTML comments?
Yes, by default. Untick Remove comments to keep them. Conditional comments that start with a bracketed if are always kept, since removing them can change how older browsers read the page.
What is the difference between cleaning and minifying HTML?
Cleaning keeps the line structure and only removes clutter. Minify goes further: it removes comments and whitespace between tags to make the file as small as the tool can, usually leaving one line.
About this tool
Clean HTML changes only whitespace and comments, never tags or attributes. Text inside pre, textarea, script and style elements is left exactly as written, so code and preformatted text keep their spacing. An unclosed comment is reported with its line number instead of swallowing the rest of the page. Remove all tags returns the visible text: script and style blocks and comments are dropped with their content, block-level tags become line breaks, and entities such as & stay as written. Beautify and Minify use the same engines as the HTML Formatter and HTML Minifier tools. Collapsing spaces can change how inline text looks only where the browser would not have shown the extra space anyway. Nothing is uploaded; the work happens in your browser.