Whitelist-based HTML Sanitizer (sanitize-html) for Vue.js Apps

Whitelist-based HTML Sanitizer (sanitize-html) for Vue.js Apps

vue-sanitize Whitelist-based HTML sanitizer (sanitize-html) for Vue.js apps


Whitelist-based HTML sanitizer (sanitize-html) for Vue.js apps.


We should always sanitize user input values on the server. Do sanitize with Vue only for necessary cases (e.g markdown preview).


npm install --save vue-sanitize


yarn add vue-sanitize


Register the plugin

import VueSanitize from "vue-sanitize";

You can pass default options too:

defaultOptions = {
    allowedTags: ['a', 'b'],
    allowedAttributes: {
      'a': [ 'href' ]
Vue.use(VueSanitize, defaultOptions);

Use it in your components:

  <div contenteditable="true" @paste="sanitize"></div>

export default {
  methods: {
    sanitize(event) {
      const html = this.$sanitize(event.clipboardData.getData('text/html'));
      //const html = this.$sanitize(
      //  event.clipboardData.getData('text/html'),
      //  {
      //    allowedTags: ['b', 'br']
      //  }
      document.execCommand('insertHTML', false, (html));


Vue.use(VueSanitize[, defaultOptions])

  • Type: Object

This plugin is dependent on sanitize-html. For details, see here https://github.com/punkave/sanitize-html#readme.

this.$sanitize(diarty[, options])

  • Type: String
  • Required: true
  • Type: Object

If you don't pass an options, the default options will be used.


Return sanitizeHtml.defaults.

Change log

Please see CHANGELOG for more information what has changed recently.


If you discover any security related issues, please email [email protected] instead of using the issue tracker.


  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D


The MIT License (MIT). Please see License File for more information.

Download Details:

Author: daichirata

Source Code: https://github.com/daichirata/vue-sanitize

vue vuejs javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

8 Popular Websites That Use The Vue.JS Framework

In this article, we are going to list out the most popular websites using Vue JS as their frontend framework. Vue JS is one of those elite progressive JavaScript frameworks that has huge demand in the web development industry. Many popular websites are developed using Vue in their frontend development because of its imperative features.

Vue Native is a framework to build cross platform native mobile apps using JavaScript

Vue Native is a framework to build cross platform native mobile apps using JavaScript. It is a wrapper around the APIs of React Native. So, with Vue Native, you can do everything that you can do with React Native. With Vue Native, you get

How to Make a Simple Vue Custom Select Component

In this article, you’ll learn how to build a Vue custom select component that can be easily be styled using your own CSS. In fact, it’s the same component that we use in production on Qvault, and you can see it in action on the playground.

Creating a Custom Tooltip Component in Vue

There are plenty of libraries out there that will have you up and running with a good tooltip solution in minutes. However, if you are like me, you are sick and tired of giant dependency trees that have the distinct possibility of breaking at any time.

Vue ShortKey plugin for Vue.js

Vue-ShortKey - The ultimate shortcut plugin to improve the UX .Vue-ShortKey - plugin for VueJS 2.x accepts shortcuts globaly and in a single listener.