Registry / security / owasp-java-html-sanitizer

owasp-java-html-sanitizer

JSON →
library20260313.1javamavenunverified

Takes third-party HTML and produces HTML that is safe to embed in your web application. Fast and easy to configure.

<dependency> <groupId>com.googlecode.owasp-java-html-sanitizer</groupId> <artifactId>owasp-java-html-sanitizer</artifactId> <version>20260313.1</version> </dependency>
INSTALL
IMPORT
SIG · OWASP-JAVA-HTML-SA
O
owasp-java-html-sanitizer
securityjavav20260313.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Sanitizers
org.owasp.html.Sanitizers

Sanitize HTML allowing only formatting and links.

import org.owasp.html.Sanitizers; import org.owasp.html.PolicyFactory; public class Example { public static void main(String[] args) { PolicyFactory sanitizer = Sanitizers.FORMATTING.and(Sanitizers.LINKS); String clean = sanitizer.sanitize("<b>hello</b> <a href='http://example.com'>link</a>"); System.out.println(clean); } }
Debug
Known issues
gotchaPolicy configuration is critical; overly permissive policies may allow XSS.
fix
Use the most restrictive policy that meets your needs, e.g., Sanitizers.BLOCKS or Sanitizers.FORMATTING.
affects: all
Upgrade
Version history
20260313.1latest on Maven
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources
owasp-java-html-sanitizer — mvn dependency:get owasp-java-html-sanitizer · libregistry