Hygiene is a lightweight and efficient PHP HTML sanitizer designed for modern PHP 8.4+ applications, providing robust protection against security risks like XSS attacks. It sanitizes raw HTML, attributes, and JSON data, offering flexible whitelisting and blacklisting to control content safety.

GitHub Repo

Keep your HTML clean with Hygiene.

Key Features

Sanitize Raw HTML

Clean raw HTML content to remove harmful elements, preventing security issues like XSS attacks and ensuring safe content rendering.

Sanitize Attributes

Sanitize attributes like src and href to ensure only safe, valid values are included, blocking malicious content.

Sanitize JSON

Remove potentially harmful or malformed characters from JSON data, ensuring it’s safe for parsing and prevents injection risks.

HTML Filter (Whitelist & Blacklist)

Filter HTML using a whitelist to allow only specific tags or a blacklist to remove unwanted elements, giving you full control over the content.

Security Vulnerabilities

If you discover a security vulnerability within Hygiene, please submit an issue on GitHub. All security vulnerabilities will be promptly addressed.

License

The Hygiene PHP utility is open-sourced software licensed under the MIT license.