Skip to content

Web Sanitizer API #1336

Open
Open

Description

@o-t-w

Description

  • The setHTML() method inserts HTML into the DOM in a way that prevents cross-site scripting attacks.
  • The parseHTML() method of the Document object provides an XSS-safe method to parse and sanitize a string of HTML in order to create a new Document.

I will limit the scope to setHTML() and Document.parseHTML().

There are separate Interop proposals for the new HTML setter methods and for the streaming methods, so please also vote for those.

Specification

https://html.spec.whatwg.org/#html-sanitization

web-feature

https://web-platform-dx.github.io/web-features-explorer/features/sanitizer/

Test Links

https://wpt.fyi/results/sanitizer-api

Additional Signals

Webkit standard position: positive

This feature has been supported since Chrome and Edge version 146 and Firefox version 148.
This tweet has 445 likes.
This Bluesky post has 203 likes.
The Sanitizer API has 79 votes in the developer signals repo, making it one of the most popular features (eleventh place out of 358 features).

Activity

  1. added
    focus-area-proposal
    on Sep 3, 2026
  2. github-actions commented on Sep 3, 2026

    @github-actions

    This comment was automatically generated based on the information you provided. Please don't edit it.

    Below is additional information about the web feature (from the web-features project) which is referenced in your proposal.
    If this doesn't accurately correspond to your proposal, please update your initial comment to include web-features: <feature-id>.
    To find feature IDs, use the web-features explorer.

    Feature Sanitizer API

    • ID: sanitizer
    • Name: Sanitizer API
    • Description: The Sanitizer API customizes the sanitization of HTML parsed and inserted into the DOM in a way that can prevent cross-site scripting attacks. You can use it with DOM APIs that accept a sanitizer option, such as parseHTML() or setHTML().
    • Baseline status: Limited Availability
    • Docs: HTML Sanitizer API
    • Developer signals: 112 votes / 2 use cases (details)
    • WPT tests: wpt.fyi results
    • More information: See the web-features explorer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    focus-area-proposal

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions