Skip to content
UniKit

HTML CSS/JS remover

Strip style and script blocks from HTML in your browser, optionally remove style and on* inline event attributes, and see block, attribute and byte counts. Nothing is uploaded.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

HTML source
Remove style attributesDrop inline style="…" on tags
Remove inline eventsDrop on* attributes such as onclick and onload
Preserve whitespaceDo not collapse blank lines left by removed blocks, and do not trim

Cleaned HTML

style/script blocks are removed following the HTML raw-text rules; every other tag and text is left as written.

Paste HTML to see the cleaned result

What this tool does

  • Strip style and script blocks from HTML someone sent you and keep just the markup skeleton
  • Clean inline style="…" and onclick attributes copied out of a rich-text editor before pasting into a CMS or email template
  • Use the byte counts to confirm how much this cleanup actually removed

Example

Input

<p style="color:red" onclick="go()">Hi</p>
<script>go()</script>

Output

<p>Hi</p>

By default both the style/onclick attributes and the script block are removed: 0 style blocks, 1 script block, 1 style attribute, 1 inline event.

Frequently asked questions

Is it an HTML beautifier or formatter?

No. It only deletes: whole style/script blocks and, depending on the switches, style and on* attributes. Every other tag, attribute order and text is left as written. It does not re-indent, fix or complete tags, and it does not validate markup. The only extra normalisation is collapsing blank lines left by removed blocks and trimming the ends, which you can turn off with "Preserve whitespace".

Can I use it as an XSS sanitizer?

No, and you should not. It works at the text level following the HTML raw-text rules: it does not parse CSS or JavaScript, does not handle href="javascript:", data: URLs, scripts inside SVG/MathML, entity encoding or obfuscated variants. Use a real sanitizer such as DOMPurify with a tag/attribute allowlist, and validate again on the server.

Which patterns are not recognised, and what happens to them?

A <script> inside a comment <!-- --> is kept as comment text. A "</script>" inside a JavaScript string ends the script block early, exactly as browsers do (the rest becomes plain text). A self-closing <script /> is treated as an empty element and only the tag is removed, while the HTML standard would treat it as a start tag. A <script> inside an attribute value is not removed. Stray </script> or </style> tags are removed but not counted.

What happens with unclosed tags?

An unclosed <script>, <style> or HTML comment, or a tag with an unterminated quote, raises an error with the reason instead of guessing a range and deleting half of your document. Add the missing closing tag or quote and try again.

How are the byte counts and percentages computed?

Bytes are counted as UTF-8 (one CJK character is 3 bytes) and the percentage is removed bytes divided by input bytes, rounded to one decimal. The numbers describe this text change only, not how much a network transfer would save.

Keywords:remove script tagsstrip inline csstrim-css-js

Related tools