HTML Cleaner - Strip Attributes, Scripts & Clutter Online

Paste messy HTML and get a clean, attribute-free skeleton plus a JSON outline of the structure - scripts, styles, comments, SVG, forms and any custom selectors removed.

Runs entirely in your browser with the native HTML parser; nothing is uploaded. Useful for content extraction, scraping pipelines, CMS migration and preparing HTML for LLM input.

HTML Cleaner - Strip Attributes, Scripts & Clutter Online
Paste messy HTML and get a clean, attribute-free skeleton plus a JSON outline of the structure - scripts, styles, comments, SVG, forms and any custom selectors removed.

About the HTML cleaner

HTML copied from real websites carries an enormous amount of baggage: framework class soup, inline styles, data-* attributes, tracking scripts, SVG icons, comment markers and layers of single-purpose wrapper divs. When what you actually want is the content structure - for a scraping pipeline, a CMS migration, a diff, or trimming a page before feeding it to a language model - all of that is noise that hides the signal and wastes tokens. This tool parses your HTML with the browser's own parser (DOMParser), then applies a configurable cleaning pass: every attribute is stripped (optionally preserving href on links so the link graph survives), script/style/comment/SVG/form nodes are dropped, elements matching your custom CSS selectors are removed (one selector per line - handy for site-specific chrome like navigation bars or cookie banners), empty leftover tags are pruned, and optionally each wrapper that contains exactly one child and no text of its own is lifted away, collapsing div-in-div-in-div nesting. Two outputs are produced side by side: the cleaned HTML, and a JSON outline of the remaining structure (tag, text, children, href) that is convenient for programmatic processing. The size badge shows how much smaller the result is - on typical modern pages the cleaned skeleton is 80-95% smaller than the input. Everything runs locally in your browser tab; the HTML never leaves your machine.

HTML cleaning examples

What each option does to a snippet.

InputOutputNotes
⟨div class="a b c" data-x="1"⟩⟨p style="color:red"⟩Hi⟨/p⟩⟨/div⟩⟨div⟩⟨p⟩Hi⟨/p⟩⟨/div⟩All attributes stripped; structure and text kept.
⟨p⟩Text⟨script⟩evil()⟨/script⟩⟨/p⟩⟨p⟩Text⟨/p⟩Script tags removed entirely.
⟨a class="btn" href="/docs"⟩Docs⟨/a⟩⟨a href="/docs"⟩Docs⟨/a⟩With 'Keep href' on, links stay usable.
⟨div⟩⟨div⟩⟨p⟩Deep⟨/p⟩⟨/div⟩⟨/div⟩⟨p⟩Deep⟨/p⟩'Lift single-child wrappers' collapses pure nesting.

How to use the HTML cleaner

  1. Paste the HTML into the input box.
  2. Tick the cleanup options you want; add site-specific CSS selectors (one per line) for elements like navbars or ad blocks.
  3. Click Clean HTML.
  4. Copy the cleaned HTML, or the JSON structure if you are processing it programmatically.
  5. The size badge tells you how much clutter was removed.

HTML cleaner FAQ

Is my HTML uploaded to a server?
No. Parsing and cleaning run entirely in your browser using the native DOMParser. The page works offline once loaded.
What do the custom selectors do?
Any element matching one of your CSS selectors (one per line) is removed before the cleaning pass - for example 'nav', '#sidebar' or 'div[class*=ads]'. Invalid selectors are skipped.
What is the JSON output for?
It is an outline of the cleaned structure - objects with tag, text, children and optionally href. It is convenient for scrapers, tests or feeding structured content to a program without re-parsing HTML.
What does 'lift single-child wrappers' mean?
If an element contains exactly one child element and no text of its own, the wrapper is removed and the child takes its place. Applied recursively, it collapses the deep div-in-div nesting common on modern sites.
Why clean HTML before sending it to an LLM?
Class names, inline styles and scripts consume tokens without adding meaning. The cleaned skeleton is typically 80-95% smaller, which cuts cost and leaves the model more room for the content itself.
Are images and line breaks kept?
The 'remove empty tags' pass explicitly keeps br and img elements even though they have no children, because they carry meaning on their own.