dompurify

security utility

DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML, and SVG. It is written in JavaScript and functions in all modern browsers including Safari, Opera (15+), Internet Explorer (10+), Firefox, and Chrome - as well as nearly any other browser using Blink or WebKit. DOMPurify is crafted by security professionals with extensive experience in web attacks and XSS.

Latest Ver 3.2.5
Homepage
Github
0
15,075
The First Line of Defense for Purity
Safely navigate the web by sanitizing harmful elements with DOMPurify.
DOMPurify is a JavaScript library specifically designed to prevent XSS attacks in web applications. It sanitizes HTML, MathML, and SVG content securely.
License: (MPL-2.0 OR Apache-2.0)
https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.2.5/purify.js
https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.2.5/purify.min.js
https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.2.5/purify.js.map
https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.2.5/purify.min.js.map

Sample Code

⚠️ Some code, including import statements, may not run properly on jsFiddle. If it fails to execute, please copy the code and try it in your own environment.
📄 HTML
<div id='example'>
  <p>Hello</p>
</div>

🧩 External JS
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/2.3.6/purify.min.js"></script>

⚙️ JavaScript
document.getElementById('example').innerHTML = DOMPurify.sanitize('<img src=x onerror=alert(1)>');
⚡ Top Tools for Developers
Text Compare

Text Comparison

Easily spot the differences between two texts.

Favicon Generator

Favicon Generator

Quickly and easily generate favicons.

Lorem Ipsum Generator

Lorem Ipsum Generator

Generate placeholder text for your designs.

Character Counter

Character Counter

Check character and word count in real time.

SRT ↔ SMI

SRT ↔ SMI Converter

Easily convert between subtitle formats.

Text Extract(OCR)

Image Text Extractor

Automatically extract text from images.