typo3/html-sanitizer
A standalone PHP HTML sanitization component from TYPO3, usable in any PHP project. Declarative Behavior settings define allowed tags, attributes, and values; visitors modify or remove nodes; builders combine presets into ready-to-use Sanitizer instances for safe HTML output.
comment, editor, email_preview, imported_html—lets product teams ship content features without re-litigating XSS rules each sprint.href on links; block javascript: and non-approved URI schemes; encode unexpected comments/tags instead of silently dropping content; support custom elements or legacy markup through closure handlers.ENCODE_INVALID_TAG and ENCODE_INVALID_COMMENT let teams choose graceful degradation over aggressive stripping. That affects how much user content survives moderation, imports, and legacy migrations.Consider it when:
Look elsewhere or complement it when:
For executives: We need a consistent way to render customer-supplied HTML without opening XSS holes. This package gives us an MIT-licensed, security-maintained PHP sanitizer with explicit allow-lists and configurable behavior. It is not a Laravel-first product, so we would wrap it in a small internal service and own our content policies. The business value is reduced security risk, faster delivery of rich-text features, and a reusable platform capability rather than repeated one-off regex fixes.
For engineering: Adopt it as a narrow security component, not as an application framework. Build a Laravel service provider, config presets, and tests around representative payloads. Pin versions, track security releases, sanitize both on ingest and render, and log sanitization outcomes. The package’s Behavior/visitor/builder model is flexible enough for role- and tenant-specific policies, but it requires deliberate configuration and upgrade testing. The low star/dependent count is an adoption-risk signal, not a functional blocker; mitigate it with internal ownership and a fallback comparison against alternatives.
How can I help you explore Laravel packages today?