Get to know MDN better
Since February 2026, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Note: This feature is available in Web Workers.
The toString() method of the TrustedScript interface returns a string which may be safely inserted into an injection sink.
None.
A string containing the sanitized script.
The constant sanitized is an object created via a Trusted Types policy. The toString() method returns a string to safely execute as a script.
| Trusted Types # trustedscripturl-stringification-behavior |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Mar 10, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.