Gathering detailed insights and metrics for @justfork/maska
Gathering detailed insights and metrics for @justfork/maska
Gathering detailed insights and metrics for @justfork/maska
Gathering detailed insights and metrics for @justfork/maska
Simple zero-dependency input mask for Vue, Svelte, Alpine.js and vanilla JS.
npm install @justfork/maska
Typescript
Module System
Node Version
NPM Version
73.1
Supply Chain
99.4
Quality
75
Maintenance
100
Vulnerability
100
License
TypeScript (91.25%)
Vue (6.85%)
Svelte (1.64%)
JavaScript (0.17%)
HTML (0.08%)
Total Downloads
3,473
Last Day
2
Last Week
6
Last Month
32
Last Year
1,194
MIT License
1,920 Stars
295 Commits
74 Forks
13 Watchers
4 Branches
11 Contributors
Updated on Jun 30, 2025
Minified
Minified + Gzipped
Latest Version
2.0.0
Package Id
@justfork/maska@2.0.0
Unpacked Size
66.78 kB
Size
13.77 kB
File Count
25
NPM Version
8.7.0
Node Version
14.17.2
Cumulative downloads
Total Downloads
Last Day
0%
2
Compared to previous day
Last Week
-14.3%
6
Compared to previous week
Last Month
-45.8%
32
Compared to previous month
Last Year
-21.5%
1,194
Compared to previous year
Simple zero-dependency input mask for Vue.js and vanilla JS. Demo and examples.
npm install maska
To load latest version from CDN you can use:
1<script src="https://cdn.jsdelivr.net/npm/maska@latest/dist/maska.js"></script>
If you load Vue.js via <script>
then just add v-maska
directive to your input:
1<input v-maska="'###'">
You can add custom tokens by passing in object instead of string to directive:
1<input v-maska="{ mask: 'Z*', tokens: { 'Z': { pattern: /[а-яА-Я]/ }}}">
With bundlers you can add global directive:
1import Maska from 'maska' 2Vue.use(Maska)
or import maska
directive for local usage in component:
1<template> 2 <form> 3 <input v-maska="'###'"> 4 </form> 5</template> 6 7<script> 8import { maska } from 'maska' 9 10export default { 11 directives: { maska } 12} 13</script>
With Vue you could use computed property as mask value. In this case mask will be reactive.
With Vue 3.x you need to explicitly add Maska plugin
or directive
to your app:
1const app = Vue.createApp({...}) 2// use as plugin 3app.use(Maska); 4// or as directive 5// app.directive('maska', Maska.maska); 6app.mount('#app');
Just load script maska.js
and init it, passing element(s) or document.querySelector
expression:
1var mask = Maska.create('.masked');
Mask could be set as data-mask
attribute on element:
1<input data-mask='##/##/####'>
or can be set by mask
option on initialization:
1var mask = Maska.create('.masked', { 2 mask: '##/##/####' 3});
You can pass custom tokens while initialization:
1var mask = Maska.create('.masked', { 2 tokens: { 'Z': { pattern: /[а-яА-Я]/ }} 3});
You also can pass custom preprocessing transformation function for entire input:
1var mask = Maska.create('.masked', { 2 tokens: { 'Z': { pattern: /[а-яА-Я]/ }}, 3 preprocessor: value => { 4 return value.toUpperCase(); 5 } 6});
You can destroy mask like that:
1var mask = Maska.create('.masked'); 2mask.destroy();
Default tokens:
1{ 2 '#': { pattern: /[0-9]/ }, 3 'X': { pattern: /[0-9a-zA-Z]/ }, 4 'S': { pattern: /[a-zA-Z]/ }, 5 'A': { pattern: /[a-zA-Z]/, uppercase: true }, 6 'a': { pattern: /[a-zA-Z]/, lowercase: true }, 7 '!': { escape: true }, 8 '*': { repeat: true }, 9 '?': { optional: true } 10}
!#
will render #
)#*
for all digits or A* A*
for CARDHOLDER NAME
)-?#*
for a digit with optional minus sign)You can add your own tokens by passing them in maska
directive or create
method at initialization (see above). Important: pattern
field should be JS regular expression (/[0-9]/
) or string without delimiters ("[0-9]"
).
While specifying custom tokens you can also add a symbol-transformation behavior such as uppercase, lowercase, or even define a transform function:
1{ 2 'T': { pattern: /[0-9]/, transform: (char) => String(Number(char) % 2) } // '1234567890' -> '1010101010' 3}
You can use mask
function directly by importing it (or using Maska.mask
if you use script tag)
1 import { mask } from 'maska' 2 3 const maskedValue = mask(value, '###')
To get raw value read data-mask-raw-value
property of input. You can subscribe to @maska
event to know when this value updates. Please see examples page.
1@maska="rawValue = $event.target.dataset.maskRawValue"
To use several masks on single input, pass array instead of string as mask value.
You could use it with Vue directives:
1<input v-maska="['+1 (###) ##-##-##', '+1 (###) ###-##-##']"> 2 3<input v-maska="{ mask: ['!#HHHHHH', '!#HHHHHH-HH'], tokens: { 'H': { pattern: /[0-9a-fA-F]/, uppercase: true }}}">
and with vanilla JS attribute, but make sure that mask value is proper JSON
, so use double quotes inside array:
1<input data-mask='["# cm", "#.# cm", "#.## cm"]'>
When used on input of type number
could have inconsistent behavior in different browsers. Use attribute inputmode
if you just need a numeric keyboard for given input.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
6 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
Found 2/25 approved changesets -- score normalized to 0
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More