Skip to main content

HTML Sanitizer

New

Remove unsafe HTML tags and attributes while keeping safe markup.

htmlsanitizexsssecurityclean
Read the guide
Shortcuts:⌘ KSearch
Removed elements & attributes

    Frequently Asked Questions

    Does this remove dangerous HTML or just hide it?

    It actively removes blocked elements like script, style, iframe, object, embed, form, input, and button. It also strips event-handler attributes and unsafe href/src values before serializing the cleaned markup.

    Why did my class, style, or id attributes disappear?

    This sanitizer keeps a very small attribute allowlist. Links only keep href, images only keep src and alt, and most other attributes are dropped.

    Can I keep links, images, or tables if I trust them?

    Yes. There are separate toggles for links, images, and tables. Turning one off unwraps or strips those elements instead of keeping them.

    Why was my custom element removed but its text content stayed?

    Unsupported tags are usually unwrapped rather than fully deleted, so their child content is preserved when possible. That is different from blocked tags like <script>, which are removed entirely.

    What is the difference between Sanitize and Strip all formatting?

    Sanitize keeps allowed markup after cleaning it. Strip all formatting ignores the allowlist and outputs text-only paragraphs built from the document text content.

    Related Tools