npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

masky-js

v1.0.4

Published

Tiny, zero-dependency JavaScript input mask — declarative via HTML data-attributes, no build or framework needed. Custom masks, prefixes, suffixes, reverse/currency masks, and built-in CPF/CNPJ validation.

Readme

Masky.js

Bundle Size

📦 Masky.js — a tiny, dependency-free JavaScript library for input masking. At ~1.3 KB gzipped it needs nothing more than a <script> tag and a data-mask attribute: no build step, no framework, no JavaScript to write.


Perfect for static sites & AI-generated pages

Masky.js is fully declarative — you add masks with HTML attributes, not code. That makes it a natural fit for static sites (Astro, Eleventy, plain HTML) and for pages built by AI tools: an LLM can add a working mask with a single attribute, with nothing to import, bundle, or initialize.

Add the script, then describe your masks with attributes:

<script src="https://cdn.jsdelivr.net/npm/masky-js"></script>

data-mask             pattern — tokens: 0=digit  A=alphanumeric  S=letter  (rest = literal)
data-mask-prefix      text prepended       e.g. "R$ "
data-mask-suffix      text appended        e.g. " kg"
data-mask-reverse     "true" → fills right-to-left (currency)
data-mask-validation  "cpf" | "cnpj"       validates on blur

<input data-mask="(00) 00000-0000">
<input data-mask="000.000.000-00" data-mask-validation="cpf">

💡 Paste that cheat sheet into your AI assistant (v0, Cursor, Claude…) and let it wire the masks into your forms.


Features

  • Tiny & dependency-free — ~1.3 KB gzipped (~1.1 KB brotli), vanilla JS, runs anywhere.
  • Fully declarative — configure everything through data-* attributes; no JS to write.
  • Automatic enhancements — derives inputmode, minlength and maxlength from the mask.
  • Prefixes, suffixes and reverse (currency) masks.
  • Built-in CPF & CNPJ validation for Brazilian forms.

Usage

Basic

<input type="text" data-mask="(00) 00000-0000" />
<script src="https://cdn.jsdelivr.net/npm/masky-js"></script>

Prefix & suffix

<input
    type="text"
    data-mask="000-000"
    data-mask-prefix="+55 "
    data-mask-suffix=" ext"
/>

CPF / CNPJ validation

<input type="text" data-mask="000.000.000-00" data-mask-validation="cpf" />
<input type="text" data-mask="00.000.000/0000-00" data-mask-validation="cnpj" />

Validation runs on blur through the native Constraint Validation API (setCustomValidity), so errors surface like any other HTML5 form validation.

Tokens

| Token | Matches | Example | | ----- | ----------------- | ------------- | | 0 | Digits (0–9) | 000123 | | A | Letters or digits | AAA1AB | | S | Letters only | SSSabc |

Any other character in the mask is treated as a literal (., -, /, (, spaces, …).

Installation

🌐 CDN

<script src="https://cdn.jsdelivr.net/npm/masky-js/dist/masky.min.js"></script>
<!-- or -->
<script src="https://unpkg.com/masky-js/dist/masky.min.js"></script>

📦 npm

npm install masky-js
import "masky-js/dist/masky.min.js";

The script runs on page load and masks every input[data-mask] it finds.

FAQ

Does it work with React, Vue or Angular? Masky.js writes straight to the input's value and scans the DOM once on load, which clashes with frameworks that own the value and re-render it. It's built for static and server-rendered HTML. Inside a controlled React/Vue component, reach for a mask solution designed for that model.

Are inputs added after page load masked? Not yet — Masky.js scans the page once on load, so inputs injected later (a modal, an SPA route) aren't picked up automatically.

Contributing

Contributions are welcome — fork the repo, create a branch, and open a pull request.

License

MIT