1. Home
  2. Tools
  3. HTML cleaner

Free · no sign-up · runs in your browser

HTML Cleaner

Strip the junk out of HTML — inline styles, classes, span and font tags, empty paragraphs, Word and Google Docs markup, scripts and invisible characters — and see the result live.

HTML input

In shortPaste the HTML, tick what to remove (inline styles, classes, spans, empty tags, Word junk and more) and the cleaned code appears instantly with a preview. The cleaner edits the document tree, so it never breaks nesting.

How to use the HTML cleaner

  1. Paste the HTML. Paste the messy code or open a file. A sample is loaded to show what the cleaner does.
  2. Tick what to remove. Sensible defaults are on: Word junk, comments, inline styles, spans, empty tags,  , extra spaces, invisible characters and scripts.
  3. Check the preview. Switch to Preview to see the cleaned content rendered.
  4. Copy the clean code. Copy it or download clean.html.

Why HTML gets dirty

Copying from Word, Google Docs, websites, email clients or AI chat tools brings along hidden baggage: style attributes on every paragraph, nested <span>s, MsoNormal classes, <o:p> tags, empty paragraphs and invisible Unicode characters. Pasted into a CMS or email template, this junk fights your stylesheet and bloats the page.

What each option removes

OptionRemoves
Word / Google Docs junkmso-* and Mso* classes, <o:p>, <w:…>, conditional comments, docs-internal-guid wrappers, generator meta tags
Comments<!-- … -->
Inline stylesEvery style="…" attribute (and <style> blocks in fragments)
Classes and IDsclass and id attributes
All other attributesEverything except href, src, alt, colspan, rowspan
Span and font tagsThe tags, keeping their text
Empty tagsElements with no text or media — repeated until none are left
&nbsp; / successive spacesNon-breaking spaces and runs of spaces
Invisible / AI watermark charactersZero-width spaces and joiners, BOM, soft hyphens, bidi marks, narrow no-break spaces
Scripts and handlers<script>, <iframe>, <object>, onclick-style attributes, javascript: links
Images / links / tables / all tagsMedia, link wrappers, table structure, or everything except text

What are "AI watermark" characters?

Text copied from some AI tools, PDFs and websites can contain invisible Unicode characters — zero-width spaces (U+200B), zero-width joiners, narrow no-break spaces (U+202F) and similar. They're invisible but break search, word counts and spacing, and some detectors look for them. The cleaner removes them all.

Why it's safer than regex cleaners

Many cleaners use find-and-replace on the raw text, which can leave half-deleted tags. This one parses the HTML into a real document tree (the same way your browser does), edits the elements, and writes it back out — so the result is always well-formed. If you're starting from a Word document, the Word to HTML converter lets you paste the formatted text directly.

Private by design: this tool runs entirely in your browser. Nothing you paste or open is uploaded to a server.

Frequently asked questions

How do I remove inline styles from HTML?

Paste the HTML here with "Remove inline styles" ticked (it's on by default). Every style="…" attribute is removed and the clean code appears on the right.

How do I remove all HTML tags and keep the text?

Tick "Remove ALL tags". For nicer plain text with line breaks and bullet points, use HTML to text.

Can it clean HTML from Microsoft Word?

Yes — "Remove Word / Google Docs junk" handles mso classes, o:p tags and conditional comments. Or paste the document itself into the Word to HTML converter.

Will it remove my links and images?

Not unless you tick those options. By default links, images and tables are kept.

Is it safe for HTML with scripts?

Yes. The preview has scripts disabled, and "Remove scripts" strips them from the output.

Related tools & guides

Updated 2026-10-22 · by the htmlonline.dev team