Skip to main content

HTML cleaner

Clean up your HTML code. Remove unnecessary attributes, styles, empty tags and more.
Clean HTML
Paste your HTML code and set the cleaning options.

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.

0 characters
0

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 &nbsp; to the necessary minimum.

Code formatting

Optionally get cleanly indented, readable HTML as output.

Cleaning HTML in four steps

  1. Paste your code on the left, or load a template with 'Load example'.
  2. 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.
  3. Click 'Clean HTML'.
  4. 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

OptionWhat 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 tagsReturns only the text without tags. Paragraphs, headings, list items and <br> become line breaks, and table cells are separated by a space.
Convert semanticallyb becomes strong, i becomes em.
Convert tables to divsReplaces table tags with div elements with classes such as table, row and cell.
Convert special characters to entitiesConverts, for example, © to &copy; and € to &euro;.
MinifyOutputs 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

Everything about the HTML cleaner
What does the HTML cleaner do?
The HTML cleaner cleans up HTML code. It can remove unnecessary attributes, inline styles, empty tags, comments and specific elements. It can also convert outdated tags to semantic ones and format the output.
When should I clean HTML?
Cleaning is most useful when you paste from Word or Google Docs, migrate a website, switch your CMS, or tidy up code in general.
Which HTML elements can be removed?
Among others, the cleaner can remove span tags, div wrappers, images, links, tables, comments, script tags and style tags. It can also remove empty tags and Word leftovers. Each option can be switched on or off on its own.
Is the HTML cleaner a security filter?
No. The cleaner cleans up formatting. On request it removes event handlers such as onclick and javascript: URLs, but it doesn't replace a sanitizer. Run HTML from outside sources through a real sanitizer before you publish it.
What does semantic conversion mean?
Semantic conversion turns outdated HTML tags into more meaningful ones. For example, <b> becomes <strong> and <i> becomes <em>. This improves readability and accessibility.
Can I search for specific text and replace it?
Yes. The HTML cleaner has an editor for any number of search and replace rules. You can use it to swap specific text patterns or HTML fragments in one pass.
Is the HTML cleaner free?
Yes. The HTML cleaner is free and works without sign-up. All processing happens in your browser.

Related tools

All tools

Changelog

Latest updates and improvements to the HTML cleaner
v1.4.0

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.
v1.3.0

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.
v1.2.0

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
v1.1.0

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.
v1.0.0

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.