Irmu
Free tool

Clean HTML

Paste messy markup and get readable HTML back. Scripts, styles, ads, tracking, nav, headers and footers removed — in your browser, nothing uploaded.

Messy HTML input
Clean HTML output
0 B in · 0 B out · 0% smallerRuns entirely in your browser — nothing is uploaded.
Code examples

Do the same thing in your own pipeline

The tool above uses the browser's HTML parser. Here is the equivalent cleanup with the standard parser in each language.

# pip install beautifulsoup4

from bs4 import BeautifulSoup, Comment

REMOVE_TAGS = ["script", "style", "noscript", "iframe", "nav", "header", "footer", "aside"]
AD_HINTS = ("ad", "advert", "sponsor", "banner", "gtm", "analytics", "doubleclick")

def clean_html(html: str) -> str:
    soup = BeautifulSoup(html, "html.parser")

    for tag in soup(REMOVE_TAGS):
        tag.decompose()

    for comment in soup.find_all(string=lambda t: isinstance(t, Comment)):
        comment.extract()

    for tag in soup.find_all(True):
        marker = " ".join(tag.get("class", [])) + " " + (tag.get("id") or "")
        if any(hint in marker.lower() for hint in AD_HINTS):
            tag.decompose()
            continue
        for attr in list(tag.attrs):
            if attr.startswith("on") or attr in ("style", "class", "id"):
                del tag[attr]

    return soup.prettify()

print(clean_html("<div class='ads'>x</div><article><p>Real content</p></article>"))
How it works

What gets removed

  • Scripts: <script>, <noscript>, <template>, inline onclick-style handlers and javascript: URLs.
  • Styles: <style> blocks, stylesheet <link> tags, every style attribute and legacy presentational tags.
  • Ads and tracking: iframes, <ins> units, 1x1 pixels and elements whose class, id or src match known ad and analytics networks.
  • Navigation and chrome: <nav>, <header>, <footer>, <aside>, breadcrumbs, pagination and their ARIA role equivalents.
  • Noise: HTML comments, tracking data-attributes, empty wrappers and — optionally — every class and id.
With Irmu

When you also need to fetch the page

Irmu returns the page HTML — rendering, proxies and retries included. Clean it with the same parsers above.

crawl_and_clean.py
# pip install requests beautifulsoup4

import os
import requests
from bs4 import BeautifulSoup

resp = requests.get(
    "https://app.irmu.com/api/crawl",
    headers={"Authorization": f"Bearer {os.environ['IRMU_API_KEY']}"},
    params={"url": "https://example.com/article", "render": "true"},
    timeout=60,
)
resp.raise_for_status()

soup = BeautifulSoup(resp.text, "html.parser")
for tag in soup(["script", "style", "noscript", "iframe", "nav", "header", "footer", "aside"]):
    tag.decompose()

print(soup.prettify()[:800])
FAQ

Questions about this tool

Turn any URL into clean data

Fetch, render and extract with one API. 1,000 free credits every month, no card required.