100% free
HTML cleaner
Cleaning options
Attributes
Tags
Content and format
The cleaner cleans up formatting and is not a security filter. Run cleaned HTML from outside sources through a real sanitizer before you publish it.
Features at a glance
Everything you need to clean up HTML.
Attribute cleanup
Remove classes, IDs, inline styles and data attributes one by one or all at once.
Tag removal
Remove span, div, script, style, image, link or table tags. The content stays for span, div and links, and is deleted with scripts, styles and tables.
Semantic conversion
Convert outdated tags such as <b> and <i> to semantic <strong> and <em>.
Search and replace
Define any number of replacement rules for specific text patterns or HTML fragments.
Whitespace reduction
Reduce repeated spaces and to the necessary minimum.
Code formatting
Optionally get cleanly indented, readable HTML as output.
Cleaning HTML in four steps
- Paste your code on the left, or load a template with 'Load example'.
- Choose your options on the 'Clean' tab. Preselected are, among others, classes, inline styles, data attributes, empty tags, comments, span tags, scripts, styles, Word leftovers, event handlers and javascript: URLs.
- Click 'Clean HTML'.
- Check the result, switch to the preview if you like, and copy the code or download it as cleaned.html.
Above the output you see by how many percent the code got smaller. 'Reset' restores the default settings. If you turn on 'Remove all tags', the options for tags, attributes, images, links, tables and semantic conversion can't be selected anymore.
Cleaning up HTML from Word or Google Docs
Text pasted from Word or Google Docs often brings classes, inline styles and empty wrappers along. The default settings remove exactly these leftovers and also turn b into strong and i into em. Still check the result in the preview. Removed classes can change the appearance if your theme needs them.
In WordPress, copy the cleaned code and paste it into a Custom HTML block in the block editor.
What each option does
| Option | What happens |
|---|---|
| Remove attributes (links and images stay) | Removes every attribute except href, src, alt and title. Links and images keep their target and alt text. |
| Remove all tags | Returns only the text without tags. Paragraphs, headings, list items and <br> become line breaks, and table cells are separated by a space. |
| Convert semantically | b becomes strong, i becomes em. |
| Convert tables to divs | Replaces table tags with div elements with classes such as table, row and cell. |
| Convert special characters to entities | Converts, for example, © to © and € to €. |
| Minify | Outputs the code without line breaks. The formatted output is skipped then. |
Search and replace in HTML
On the 'Search and replace' tab you create any number of rules. The tool searches for the text exactly as you type it and doesn't treat characters such as ? or ( as regex. The rules run after tags and attributes are removed, but before special characters are converted, whitespace is reduced and the output is formatted.
An example: search for http:// and replace it with https://, and you switch all old links in one pass.
Frequently asked questions
What does the HTML cleaner do?
When should I clean HTML?
Which HTML elements can be removed?
Is the HTML cleaner a security filter?
What does semantic conversion mean?
Can I search for specific text and replace it?
Is the HTML cleaner free?
Related tools
Changelog
November 20, 2026
Paragraphs stay separate, empty cells stay
- • Fixed: 'Remove all tags' glued paragraphs together, so <p>a</p><p>b</p> became "ab". Paragraphs, headings, list items and <br> now become line breaks.
- • Fixed: 'Remove empty tags' deleted empty table cells (td, th) and iframes. Both now stay.
- • Fixed: in the replacement text, patterns such as $& or $1 were read as special characters. The text now applies literally.
- • Fixed: search and replace rules were not applied with 'Remove all tags'.
- • With 'Remove all tags', the options for attributes, images, links, tables and semantic conversion are now disabled too, because they have no effect then.
- • The FAQ no longer mentions custom tags, which never existed. The overview makes clear for which tags the content is kept.
November 18, 2026
Word leftovers, event handlers and javascript: URLs
- • Added removal of Word leftovers (o:p tags, mso styles, conditional comments), on by default.
- • Added removal of event handlers such as onclick and onerror, on by default.
- • Added removal of javascript: URLs in href, src and similar attributes, on by default. The link text stays.
- • Added a note in the interface: the cleaner cleans up formatting and is not a security filter.
November 17, 2026
Underlines are kept
- • Added a guide with instructions and use cases directly below the tool.
- • Added related tools at the end of the page.
- • The u tag is kept during semantic conversion, so underlines no longer disappear with the default settings.
- • The option for removing attributes is now called 'Remove attributes (links and images stay)'.
Show older versions
December 28, 2025
Minify mode and performance
- • Added a minify mode for maximum compression.
- • Added single-line output without line breaks.
- • Added aggressive whitespace removal.
- • Improved the removal of inline styles.
- • More precise display of the size reduction.
December 9, 2025
Launch
- • Extensive HTML cleaning options.
- • Removal of attributes and styles.
- • Semantic conversion of tags.
- • Removal of empty tags and comments.
- • Multiple search and replace rules.
- • Real-time preview.
- • HTML formatting and indentation.
- • Processing in the browser.