Skip to content

HTML Sanitizer

Clean untrusted HTML by keeping only safe tags and attributes. The sanitizer, built on the sanitize-html library, removes scripts, event handler attributes, javascript: links, iframes and every element or attribute outside the allowed list, and keeps the text content. Choose common formatting, basic formatting or text only, and optionally allow images and classes.

Reset

Frequently asked questions

What does the default profile allow?

The default list of sanitize-html: headings, paragraphs, lists, blockquotes, code, tables, links and inline formatting such as b, i, em, strong and span. Links keep href, name and target. Images are removed unless you allow them.

What does the basic profile allow?

Only a, b, blockquote, br, code, em, i, li, ol, p, pre, strong, u and ul, with href as the only attribute on links. It suits comments and short user content.

Which link schemes are kept?

http, https, ftp, mailto and tel. Links with other schemes, such as javascript: or data:, lose their href, and protocol-relative links starting with // are removed too.

What happens to the content of removed tags?

Disallowed tags are removed but their text is kept. The content of script, style and textarea elements and similar tags is removed completely, because it is not readable text.

Is sanitizing once enough to prevent XSS?

Sanitize HTML when you store or render it, and escape everything else you insert into a page. Use the same allowed list on the server where the content is saved, because anything done only in a browser can be bypassed.

What does text only do?

It removes every tag and keeps only the text, with HTML entities such as & left in place, so the result can be shown as HTML without markup.

About OneClick Pro

OneClick Pro is a free collection of more than 150 web tools for everyday work: converting images and units, formatting and validating code, checking domains and SEO, and working with text, dates and numbers. Every tool runs without registration or subscription, and what you enter is only used to calculate your result and is never stored. Use it as a quick toolbox for one-off tasks, or bookmark the tools you rely on every day.