DOM & HTML
HTML Sanitizer
Sanatize untrusted HTML strings before insertion into the DOM using the native Sanitizer API.
Checking support...
Feature Not SupportedThis browser does not support the HTML Sanitizer Web API feature. Try testing in a modern browser (such as Chrome, Edge, Safari, or Firefox).
Advertisement
Interactive Input Workspace
Ready for input
Web API Execution Output
Result output will be displayed here after processing...
Native JavaScript Code Example (Zero Libraries)
if ('Sanitizer' in window) {
const sanitizer = new Sanitizer();
element.setHTML('<b>safe</b><script>alert(1)</script>', { sanitizer });
}About the HTML Sanitizer Web API
The HTML Sanitizer API allows developers to clean untrusted HTML strings safely before injecting into the document.
Specification:W3C & WHATWG Web API Standard
Sponsored Content