HTML Sanitizer
Paste untrusted HTML to remove scripts, event handlers, dangerous URLs and anything not on the allowlist. Input and output are displayed as escaped text only; nothing you paste is rendered as live HTML on this page.
The two allowlists
GitHub-style (default schema). This is defaultSchema from rehype-sanitize, modeled on what GitHub allows in user content: common text, list, table and media elements, a short list of attributes, and a URL protocol allowlist: links may use http, https, mailto, irc, ircs or xmpp, images only http and https, and relative URLs are allowed. Scripts, styles, iframes, forms, event handlers and style attributes are removed. id and name values get a user-content- prefix to prevent DOM clobbering.
Text formatting only. A stricter schema written for this tool, based on the default schema: paragraphs, headings, emphasis, lists, quotes, code and links with http, https or mailto URLs. Images, tables and everything else are removed.
How to use sanitized HTML safely
- Sanitize on the server, at the point where untrusted HTML enters your system or right before it is rendered. Client-side sanitizing alone can be bypassed by anyone who calls your API directly.
- Sanitize last: run
rehype-sanitizeafter plugins that add markup, or allow what those plugins add in the schema. - Keep a Content Security Policy as a second layer of defense.
Read Sanitize HTML safely with rehype-sanitize for schema customization and pitfalls. The removal report compares element and attribute counts before and after sanitizing; property names are shown as hast names (for example onClick for the onclick attribute).
Packages used
rehype-parse, rehype-sanitize, rehype-stringify, bundled locally from npm and run in a Web Worker. Your input stays on your device.
Other tools: HTML Formatter · HTML Minifier · HTML to Markdown · HTML Playground · Plugin Explorer