Description
The W3C repository for Trusted Types, a browser API that helps prevent DOM-based cross-site scripting in modern web applications. The repository holds the specification draft and a polyfill implementation. The API is available natively in browsers based on Chromium 83 and later. The polyfill comes in two browser variants. The api_only build defines the API, so policies and types can be created. The full build also enforces types in the DOM, based on the policy the document infers from its Content Security Policy. The polyfill is also published as an npm package named trusted-types for Node.js, and it supports CommonJS and ES modules. A tinyfill is described too: a small snippet that polyfills the createPolicy function without enforcement, so most applications keep working in both enforcing and legacy browsers. Compiled files are kept in the dist directory.…
Highlights
- Browser API that helps prevent DOM-based XSS
- Polyfill with api_only and full browser builds
- npm package for Node.js with CommonJS and ES modules
- Tinyfill for createPolicy without enforcement
Ratings & Reviews
No ratings yet
Be the first to rate Trusted Types.
People also visit
Trusted Types FAQ
What problem does it solve?
DOM-based cross-site scripting in web applications.
Which browsers support it natively?
Chromium-based browsers from version 83 onward, according to the repository.
What is the difference between the builds?
The api_only build defines the API. The full build also enforces types in the DOM based on the document's Content Security Policy.
Can I use it in Node.js?
Yes. The polyfill is an npm package named trusted-types and supports CommonJS and ES modules.
Where is the specification?
The repository hosts the specification draft and the polyfill code on GitHub at w3c/trusted-types.
What are the best Trusted Types alternatives?
Popular alternatives to Trusted Types include Parallel DOM, TrustCaptcha and Run. See all Trusted Types alternatives





