{"_id":"masky-js","_rev":"5-cd9d3df643aa562bc6daffb0225a5b13","name":"masky-js","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"masky-js","version":"1.0.0","keywords":["JavaScript","form-validation","input-mask","mask","masking","cpf","cnpj"],"author":{"name":"EduardoVillao"},"license":"MIT","_id":"masky-js@1.0.0","maintainers":[{"name":"eduardovillao","email":"dev@eduardovillao.me"}],"homepage":"https://github.com/eduardovillao/masky-js","bugs":{"url":"https://github.com/eduardovillao/masky-js/issues"},"dist":{"shasum":"13e43f9020a4d05e777e0812acd1f2c2868268a7","tarball":"https://registry.npmjs.org/masky-js/-/masky-js-1.0.0.tgz","fileCount":4,"integrity":"sha512-lt399xKufDenTB2BfGEVBK0n5CoXphXml1FSIrXcp/pbDAiTaFi875xDItWdDH2kptpXOlwb0Uk7LesKvdbrbQ==","signatures":[{"sig":"MEQCICuIHRzD3kvBnTuR55f3QI2K0ToT6KlO9V/s84vwXVRVAiASNNlaNhHppKhhTHVuHi92bwkhhV8uMoMjEgOY33/0rA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8265},"main":"dist/masky.min.js","gitHead":"2dc1d1e1f98bf7f1da219c1258b754973137934a","scripts":{"build":"webpack"},"_npmUser":{"name":"eduardovillao","email":"dev@eduardovillao.me"},"_npmVersion":"10.9.2","description":"A lightweight and flexible JavaScript library for input masking. Supports custom masks, prefixes, suffixes, and built-in CPF/CNPJ validation for forms.","directories":{},"_nodeVersion":"23.5.0","_hasShrinkwrap":false,"devDependencies":{"webpack":"^5.97.1","webpack-cli":"^6.0.1","esbuild-loader":"^4.2.2","css-minimizer-webpack-plugin":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/masky-js_1.0.0_1737396654573_0.47177562822604435","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"masky-js","version":"1.0.1","keywords":["JavaScript","form-validation","input-mask","mask","masking","cpf","cnpj"],"author":{"name":"EduardoVillao"},"license":"MIT","_id":"masky-js@1.0.1","maintainers":[{"name":"eduardovillao","email":"dev@eduardovillao.me"}],"homepage":"https://github.com/eduardovillao/masky-js","bugs":{"url":"https://github.com/eduardovillao/masky-js/issues"},"dist":{"shasum":"50343318872ec478f6b915bd52216f3aaf9ba22e","tarball":"https://registry.npmjs.org/masky-js/-/masky-js-1.0.1.tgz","fileCount":4,"integrity":"sha512-Jkuo/gCMJoQUFR7HdxBPyGs9q13kxguhZKEOgpmv4CjkocP15hf5KKhQXvaJDsT+dknT6TKHGBX0vvtNhk/x6g==","signatures":[{"sig":"MEUCIQDKg/6GbhnSW4S7JTy2vDHA1AncBnb81DJQZw0nhkMWkwIgFvDFdQyQnF9IPkClVA2eR6b1kTdCixjBEAXNlotvtsI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8806},"main":"dist/masky.min.js","gitHead":"78b9165a8951144ad340695a4ebb2c229241c2a1","scripts":{"build":"webpack"},"_npmUser":{"name":"eduardovillao","email":"dev@eduardovillao.me"},"_npmVersion":"10.9.2","description":"A lightweight and flexible JavaScript library for input masking. Supports custom masks, prefixes, suffixes, and built-in CPF/CNPJ validation for forms.","directories":{},"_nodeVersion":"23.5.0","_hasShrinkwrap":false,"devDependencies":{"webpack":"^5.97.1","webpack-cli":"^6.0.1","esbuild-loader":"^4.2.2","css-minimizer-webpack-plugin":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/masky-js_1.0.1_1737397650800_0.41447942935350635","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"masky-js","version":"1.0.2","keywords":["JavaScript","form-validation","input-mask","mask","masking","cpf","cnpj"],"author":{"name":"EduardoVillao"},"license":"MIT","_id":"masky-js@1.0.2","maintainers":[{"name":"eduardovillao","email":"dev@eduardovillao.me"}],"homepage":"https://github.com/eduardovillao/masky-js","bugs":{"url":"https://github.com/eduardovillao/masky-js/issues"},"dist":{"shasum":"ca1acd3742c8927e02b655117c17479d2103bc1a","tarball":"https://registry.npmjs.org/masky-js/-/masky-js-1.0.2.tgz","fileCount":4,"integrity":"sha512-Xldacgm5GPFiSFCHHxX/xAWNQC1G4kuxO3aJxwF7qaXhbeNIfwb1nlEgpsCBpuIm5M1Zw5N8jCs7QulujFr7wg==","signatures":[{"sig":"MEQCIGA1cirxY7IKgrDN8NSvnwjljbMalvQ2Wu2E7GMXLemQAiAA8vFVVwc8VVPMWAOJuF4xIo/hQ1qsKrzYgjKF5Mbg5A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/masky-js@1.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":9039},"main":"dist/masky.min.js","gitHead":"181fffb0300f43e31a1fa6a7238fb38c23eeb353","scripts":{"build":"webpack"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:2949c571-ea24-4959-9283-95f0c6f54390"}},"repository":{"url":"git+https://github.com/eduardovillao/masky-js.git","type":"git"},"_npmVersion":"11.6.2","description":"A lightweight and flexible JavaScript library for input masking. Supports custom masks, prefixes, suffixes, and built-in CPF/CNPJ validation for forms.","directories":{},"_nodeVersion":"24.13.0","_hasShrinkwrap":false,"devDependencies":{"jsdom":"^27.4.0","vitest":"^4.0.18","webpack":"^5.97.1","webpack-cli":"^6.0.1","esbuild-loader":"^4.2.2","css-minimizer-webpack-plugin":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/masky-js_1.0.2_1769547749063_0.9150171404093632","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"masky-js","version":"1.0.3","keywords":["javascript","vanilla-js","input-mask","inputmask","text-mask","mask","masking","currency-mask","phone-mask","cpf","cnpj","cpf-validation","cnpj-validation","zero-dependency","form-validation","astro"],"author":{"name":"EduardoVillao"},"license":"MIT","_id":"masky-js@1.0.3","maintainers":[{"name":"eduardovillao","email":"dev@eduardovillao.me"}],"homepage":"https://github.com/eduardovillao/masky-js","bugs":{"url":"https://github.com/eduardovillao/masky-js/issues"},"dist":{"shasum":"b267ca935475058c63c34fa92577cf91b3a4ae0b","tarball":"https://registry.npmjs.org/masky-js/-/masky-js-1.0.3.tgz","fileCount":4,"integrity":"sha512-nfimPSvB8atWKhNUqlQ5iRKl70ftIeK5pBlAMX1gELxdZUdbiv4FEFbCxQG0xSxrncWinrSTt6KWh9ETznZr6Q==","signatures":[{"sig":"MEYCIQCh5PWfoI+izTjh7lWniaZG3GsK+5TPq/YsvgBSSev3jwIhAMYw2ZutADUJgBVQnL0jNt1ZvDOU+uKkh+LczMRNL0CV","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/masky-js@1.0.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":8956},"main":"dist/masky.min.js","gitHead":"37b6692030e73db7334266ddef589c8d7d027e75","scripts":{"build":"terser src/masky.js --compress --mangle --toplevel --ecma 2020 -o dist/masky.min.js"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:2949c571-ea24-4959-9283-95f0c6f54390"}},"repository":{"url":"git+https://github.com/eduardovillao/masky-js.git","type":"git"},"_npmVersion":"11.16.0","description":" 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.","directories":{},"_nodeVersion":"24.18.0","_hasShrinkwrap":false,"devDependencies":{"jsdom":"^27.4.0","terser":"^5.48.0","vitest":"^4.0.18"},"_npmOperationalInternal":{"tmp":"tmp/masky-js_1.0.3_1783361263782_0.4890901126360421","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"masky-js","version":"1.0.4","description":" 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.","repository":{"type":"git","url":"git+https://github.com/eduardovillao/masky-js.git"},"main":"dist/masky.min.js","scripts":{"build":"terser src/masky.js --compress --mangle --toplevel --ecma 2020 -o dist/masky.min.js"},"keywords":["javascript","vanilla-js","input-mask","inputmask","text-mask","mask","masking","currency-mask","phone-mask","cpf","cnpj","cpf-validation","cnpj-validation","zero-dependency","form-validation","astro"],"author":{"name":"EduardoVillao"},"license":"MIT","bugs":{"url":"https://github.com/eduardovillao/masky-js/issues"},"homepage":"https://github.com/eduardovillao/masky-js","devDependencies":{"jsdom":"^27.4.0","terser":"^5.48.0","vitest":"^4.0.18"},"gitHead":"cd1f7c5e2d281681abf3c901e40b02ce5e3be5a1","_id":"masky-js@1.0.4","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-+qvFUYw1RcO/md5WVnnLYZLYURVgdfLDQNhYsx08b/tJ3Lf52plW23Oe2Tl2BjZqVeBAx0MTnt851v87YpXpaQ==","shasum":"3757c7e223d4714e5dafd40c344a86d4d884f8be","tarball":"https://registry.npmjs.org/masky-js/-/masky-js-1.0.4.tgz","fileCount":4,"unpackedSize":8960,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/masky-js@1.0.4","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIELuUalO3Q1AJhmUaW8FrtiV58dO7fXNcDWoSxR8E5lMAiEAsaMuxYwfItCTmOHttHGfBIqWNoDXJEHCEfMAjrtqS2o="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:2949c571-ea24-4959-9283-95f0c6f54390"}},"directories":{},"maintainers":[{"name":"eduardovillao","email":"dev@eduardovillao.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/masky-js_1.0.4_1783362493050_0.045190619207917004"},"_hasShrinkwrap":false}},"time":{"created":"2025-01-20T18:10:54.571Z","modified":"2026-07-06T18:28:13.463Z","1.0.0":"2025-01-20T18:10:54.779Z","1.0.1":"2025-01-20T18:27:30.966Z","1.0.2":"2026-01-27T21:02:29.262Z","1.0.3":"2026-07-06T18:07:43.910Z","1.0.4":"2026-07-06T18:28:13.220Z"},"bugs":{"url":"https://github.com/eduardovillao/masky-js/issues"},"author":{"name":"EduardoVillao"},"license":"MIT","homepage":"https://github.com/eduardovillao/masky-js","keywords":["javascript","vanilla-js","input-mask","inputmask","text-mask","mask","masking","currency-mask","phone-mask","cpf","cnpj","cpf-validation","cnpj-validation","zero-dependency","form-validation","astro"],"repository":{"type":"git","url":"git+https://github.com/eduardovillao/masky-js.git"},"description":" 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.","maintainers":[{"name":"eduardovillao","email":"dev@eduardovillao.me"}],"readme":"# Masky.js\n\n[![Bundle Size](https://img.shields.io/bundlephobia/minzip/masky-js)](https://bundlephobia.com/package/masky-js)\n\n📦 **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.\n\n---\n\n## Perfect for static sites & AI-generated pages\n\nMasky.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.\n\nAdd the script, then describe your masks with attributes:\n\n```\n<script src=\"https://cdn.jsdelivr.net/npm/masky-js\"></script>\n\ndata-mask             pattern — tokens: 0=digit  A=alphanumeric  S=letter  (rest = literal)\ndata-mask-prefix      text prepended       e.g. \"R$ \"\ndata-mask-suffix      text appended        e.g. \" kg\"\ndata-mask-reverse     \"true\" → fills right-to-left (currency)\ndata-mask-validation  \"cpf\" | \"cnpj\"       validates on blur\n\n<input data-mask=\"(00) 00000-0000\">\n<input data-mask=\"000.000.000-00\" data-mask-validation=\"cpf\">\n```\n\n💡 Paste that cheat sheet into your AI assistant (v0, Cursor, Claude…) and let it wire the masks into your forms.\n\n---\n\n## Features\n\n- **Tiny & dependency-free** — ~1.3 KB gzipped (~1.1 KB brotli), vanilla JS, runs anywhere.\n- **Fully declarative** — configure everything through `data-*` attributes; no JS to write.\n- **Automatic enhancements** — derives `inputmode`, `minlength` and `maxlength` from the mask.\n- **Prefixes, suffixes and reverse (currency) masks.**\n- **Built-in CPF & CNPJ validation** for Brazilian forms.\n\n---\n\n## Usage\n\n**Basic**\n\n```html\n<input type=\"text\" data-mask=\"(00) 00000-0000\" />\n<script src=\"https://cdn.jsdelivr.net/npm/masky-js\"></script>\n```\n\n**Prefix & suffix**\n\n```html\n<input\n    type=\"text\"\n    data-mask=\"000-000\"\n    data-mask-prefix=\"+55 \"\n    data-mask-suffix=\" ext\"\n/>\n```\n\n**CPF / CNPJ validation**\n\n```html\n<input type=\"text\" data-mask=\"000.000.000-00\" data-mask-validation=\"cpf\" />\n<input type=\"text\" data-mask=\"00.000.000/0000-00\" data-mask-validation=\"cnpj\" />\n```\n\nValidation runs on `blur` through the native Constraint Validation API (`setCustomValidity`), so errors surface like any other HTML5 form validation.\n\n## Tokens\n\n| Token | Matches           | Example       |\n| ----- | ----------------- | ------------- |\n| `0`   | Digits (0–9)      | `000` → `123` |\n| `A`   | Letters or digits | `AAA` → `1AB` |\n| `S`   | Letters only      | `SSS` → `abc` |\n\nAny other character in the mask is treated as a literal (`.`, `-`, `/`, `(`, spaces, …).\n\n## Installation\n\n**🌐 CDN**\n\n```html\n<script src=\"https://cdn.jsdelivr.net/npm/masky-js/dist/masky.min.js\"></script>\n<!-- or -->\n<script src=\"https://unpkg.com/masky-js/dist/masky.min.js\"></script>\n```\n\n**📦 npm**\n\n```bash\nnpm install masky-js\n```\n\n```js\nimport \"masky-js/dist/masky.min.js\";\n```\n\nThe script runs on page load and masks every `input[data-mask]` it finds.\n\n## FAQ\n\n**Does it work with React, Vue or Angular?**\nMasky.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.\n\n**Are inputs added after page load masked?**\nNot yet — Masky.js scans the page once on load, so inputs injected later (a modal, an SPA route) aren't picked up automatically.\n\n## Contributing\n\nContributions are welcome — fork the repo, create a branch, and open a pull request.\n\n## License\n\n[MIT](https://mit-license.org/)\n","readmeFilename":"README.md"}