DOM Purify is a JavaScript library designed to clean HTML strings by removing unwanted characters and attributes before rendering them into the document.
It provides methods for:
The API is commonly used in web applications to ensure safe rendering of user-generated content.
const html = 'Hello, world!
';
const sanitized = DOMPurify.html(html);
console.log(sanitized);
Output:
Hello, world!
This example demonstrates how DOM Purify cleans HTML by removing unsafe characters and attributes.
You can use DOM Purify in your projects by including its script directly in your HTML file:
// Include DOM Purify via CDN
DOM Purify is licensed under the MIT License, allowing free use and modification for both commercial and non-commercial projects.
If you have questions about DOM Purify or need help integrating it into your project, please contact us at: