๐Ÿ›ก๏ธ HTML Sanitizer

Safely filter XSS attack code, dangerous tags and attributes with whitelist mode

Zero Dependencies ยท Works Offline

๐Ÿ“ Input HTML

โš™๏ธ Sanitization Mode

Allowed tags:

Allowed attributes:

๐Ÿ“Š Sanitization Stats

0
Tags Removed
0
Attrs Removed
0
Comments Removed

Removed content:

โœ… Sanitized Result

๐Ÿ“– What can the HTML Sanitizer do?

The HTML Sanitizer is an online security tool for filtering potentially dangerous content from HTML code. It removes XSS attack vectors (script tags, event handler attributes, javascript: protocols) while preserving safe HTML tags and attributes, ensuring user-submitted HTML content can be safely displayed.

Core Features

How to Use

  1. Paste the HTML code you want to sanitize in the input area
  2. Select sanitization mode (whitelist recommended)
  3. The tool automatically sanitizes and shows results and statistics
  4. Review the removed content list to confirm filtering is correct
  5. Copy the sanitized result or download as an HTML file

Use Cases

Case 1: Web Developers

Sanitize user-submitted HTML content before display to prevent XSS attacks and protect website and user security.

Case 2: Content Management Systems

Filter HTML output from rich text editors to ensure only safe formatting tags are preserved.

Case 3: Security Auditing

Analyze HTML code for potential security risks and identify attack vectors that could be exploited.

Extended Knowledge

XSS (Cross-Site Scripting) is one of the most common web security vulnerabilities. Attackers inject malicious scripts into web pages to steal user cookies, session tokens, or even control user browsers. HTML sanitization is an important defense against XSS, blocking script execution paths by removing dangerous HTML elements and attributes. OWASP recommends using whitelist-based HTML sanitization, as blacklist approaches can easily miss new attack techniques.

๐Ÿ“– FAQ

What is HTML sanitization?

HTML sanitization is the process of filtering potentially dangerous content from HTML code, including removing script tags, event handler attributes, javascript: protocol links and other XSS attack vectors, while preserving safe HTML tags and attributes.

Why is HTML sanitization needed?

When user-submitted HTML content needs to be displayed on a page, unsanitized HTML may contain malicious scripts leading to XSS attacks. HTML sanitization prevents script injection and protects user data security.

What is the difference between whitelist and blacklist modes?

Whitelist mode only allows specified safe tags and attributes through, removing everything else - higher security. Blacklist mode only removes specified dangerous tags and attributes, keeping everything else - more flexible but less secure.

Which HTML tags and attributes are dangerous?

Dangerous tags include: script, iframe, object, embed, applet, form, input, meta, link, base. Dangerous attributes include: all on* event attributes, javascript: protocol, data: protocol, expression() in style.

Is sanitized HTML completely safe?

Whitelist-mode sanitized HTML is safe in most scenarios, but no 100% guarantee exists. Use together with CSP (Content Security Policy) and regularly update whitelist rules.

HTML Sanitizer | No Signup, Client-Side ยท No Server Uploads

Feedback: dexshuang@google.com