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 TrustedHTML interface returns a string which may safely inserted into an injection sink.
None.
A string containing the sanitized HTML.
The constant escaped is an object created via the Trusted Types policy escapeHTMLPolicy. The toString() method returns a string to safely insert into a document.
| Trusted Types # trustedhtml-stringification-behavior |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Aug 3, 2024 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.