← All text tools

HTML Sanitizer

Clean pasted HTML of scripts, event handlers and unsafe links with an allow-list you can edit, see exactly what was removed and preview the safe result.

  • Free
  • No sign-up
  • Works on any device

About HTML Sanitizer

Pasted or generated HTML often carries script tags, onclick handlers, javascript: links and iframes. This sanitizer parses the markup with the browser's own parser and rebuilds it using only the tags, attributes and link schemes you allow. Dangerous elements such as script, style, iframe, object and svg are dropped with their content, unknown tags are unwrapped so the text stays, event handlers and unsafe URLs are removed, and links that open a new tab get noopener. A table shows exactly what was removed, and a sandboxed preview shows the safe result.

How to use HTML Sanitizer

  1. Paste the HTML you want to clean.
  2. Edit the allowed tag list and link schemes, and tick the optional attributes you want to keep.
  3. Read the removal table, check the preview, and copy the clean HTML.

Why use this tool?

Also known as

Frequently asked questions

Is client-side sanitizing enough for user content?

No. It is handy for cleaning snippets, but HTML from visitors must also be sanitized on your server with a maintained library, because the final page may parse it differently.

How is this different from stripping tags?

Stripping removes all markup. This keeps harmless formatting such as paragraphs, lists, links and images while removing only what could run code or load other pages.

What happens to a link with javascript: in it?

The href attribute is removed and the link text stays. Schemes are checked after control characters and spaces are stripped, which defeats the usual disguises.

Is HTML Sanitizer free?

Yes. HTML Sanitizer on Toolipedia is free to use, with no sign-up and no watermark.

Is it safe to use?

Yes. Everything is worked out in your browser, and nothing you enter is sent to our server.

Does it work on my phone?

Yes. It works in any modern browser on Android and iPhone, as well as on tablets and computers. There's nothing to install.

Do I need an account?

No. Just open the page and use the tool. There's no sign-up and no email needed.