v146 · Security · Custom Sanitizer Config
Custom Sanitizer Config
The Sanitizer constructor accepts a configuration object that limits allowed elements and attributes below the already-safe default. Choose a preset for a common use case — comment box, rich-text editor, or plain text only — then edit the test HTML to see what survives each policy.
Chrome 146 required for the Sanitizer API. In older browsers the demo shows what the policy would produce but uses a simplified JavaScript fallback — not a real sanitizer.
choose a policy
Comment box
Allow bold, italic, and safe links. Block everything else including images and headings.
Rich text editor
Allow headings, paragraphs, lists, tables, links, and basic formatting. Block scripts and media.
Strict — links only
Allow only <a href> with safe URLs. All other markup stripped to text.
Plain text only
No elements at all — only raw text nodes survive. Equivalent to textContent.