html-janitor
Sanitises HTML
HTML Janitor Explanation
HTML Janitor is a tool that cleans up HTML code by removing potentially dangerous or unwanted elements. Think of it like a filter for web content: if you're accepting HTML from users (like in a comment system, a rich text editor, or a content management system), you need to make sure it doesn't contain malicious code or mess up your page's layout. This tool strips out anything you don't want to allow, leaving behind only the safe, approved parts.
The way it works is straightforward. You give it some HTML code and tell it which tags and attributes you want to keep. It then goes through that code and removes everything else. For example, you might want to allow bold and italic text but block embedded scripts or link elements that could be harmful. The tool does this filtering automatically, so you don't have to manually inspect every piece of HTML that comes in.
You'd use this if you're building any application that lets users write or paste in HTML. Common examples include message boards, blog platforms, collaborative document editors, or any form where people can format their text. It's especially important if you're worried about security—someone could try to sneak in malicious code through HTML if you don't filter it properly. HTML Janitor makes that filtering simple and reliable.
The project is set up to work in different JavaScript environments. Whether you're using it in the browser, in Node.js, or in various build systems, it's designed to be compatible. You can install it through either Bower or npm, making it easy to add to an existing project.