Not TestedTesting not done, may not work properly
DOM & HTML

HTML Sanitizer

Sanatize untrusted HTML strings before insertion into the DOM using the native Sanitizer API.

Checking support...
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