Guide · Open source
How to use zxcvbn: install and read password strength scores
Updated · written with AI from the project's own documentation and checked against our catalogue data
zxcvbn is an open-source password strength estimator that you add to a sign-up or password reset form to show users how guessable a password is. This guide is for developers and teams who want to build a strength meter in JavaScript or on Node.js. After reading it you will know how to install the library, call it, and read its score, guess estimate and feedback messages.
Quick start
- 1Check prerequisites. For the npm method, make sure Node.js is installed. The README lists Node.js as the prerequisite for npm install.
- 2Install the package. Run npm install zxcvbn in your project folder.
- 3Test a password. In Node.js, require zxcvbn and call it with a sample password such as Tr0ub4dour&3 to see the result object.
- 4Read the score. Use result.score, an integer from 0 to 4, to drive a strength bar or label.
- 5Show feedback. When the score is 2 or lower, display result.feedback.warning and suggestions to guide the user.
- 6Load it only where needed. Add the library to registration and password reset pages rather than every page, because the minified bundle is several hundred kilobytes.
What zxcvbn checks in a password
zxcvbn is a password strength estimator inspired by password crackers. It uses pattern matching and conservative estimation to recognize common passwords, common names and surnames, popular English words, dates, repeats, sequences, keyboard patterns and l33t speak.
Because it looks for patterns rather than applying fixed rules, it can rate passphrases and other styles highly when they contain enough uncommon words. The README presents it as an alternative to composition rules such as requiring three of lowercase, uppercase, numbers and symbols.
- Common passwords, names, census surnames and dictionary words
- Dates, repeats such as aaa, and sequences such as abcd
- Keyboard patterns such as qwertyuiop and simple substitutions like l33t speak
Install zxcvbn with npm
For Node.js projects, the README gives the npm install method. Node.js is the prerequisite for this method. zxcvbn works the same on the server as in the browser.
The README also documents Bower and manual installation, where you add dist/zxcvbn.js with a script tag. When no CommonJS or AMD loader is detected, the library adds a single zxcvbn() function to the global namespace.
npm install zxcvbnCall zxcvbn and read the result
zxcvbn() takes one required argument, the password, and an optional list of user inputs. The README shows a quick check in Node.js using a sample password. The result object includes guesses, guesses_log10, crack_times_seconds, crack_times_display, score and feedback.
The score is an integer from 0 to 4. The README defines 0 as too guessable, 1 as very guessable, 2 as somewhat guessable, 3 as safely unguessable and 4 as very unguessable. The feedback object is set when the score is 2 or lower and includes a warning field that explains what is wrong.
- score: integer 0-4, useful for a strength bar
- guesses: estimated guesses needed to crack the password
- crack_times_display: friendly strings such as less than a second or centuries
- feedback.warning: explains what is wrong when score is 2 or lower
var zxcvbn = require('zxcvbn');
zxcvbn('Tr0ub4dour&3');Show the strength meter in a sign-up form
The README says zxcvbn() is typically called in response to user events such as filling in a password. You can run it on each change to the password field and map the score to a strength bar.
The library is several hundred kilobytes minified and gzipped, so the README recommends not bundling it into every page. Load it on registration and password reset pages, and fetch it after the initial page renders, since the check is not needed on page load.
- Call zxcvbn on each input event of the password field
- Map result.score (0-4) to your bar or label
- Pass user-specific words such as the username as user_inputs
- Load the script only on pages where passwords are entered
Load zxcvbn in the browser
For a plain web page, add the script from dist/zxcvbn.js to your HTML. To check that it loaded, open the page in a browser and type zxcvbn('Tr0ub4dour&3') into the console. If you use RequireJS, import the module as a dependency and call zxcvbn inside the callback.
The README also explains how the browserify build is generated, including the coffeeify transform, since the source is written in CoffeeScript.
<script src="bower_components/zxcvbn/dist/zxcvbn.js"></script>Know the limits before you rely on it
The README describes zxcvbn's output as estimates, not certainty. A high score does not guarantee security, so treat the score as guidance for users and keep your server-side protections such as salted, slow password hashing.
The crack time figures are back-of-the-envelope scenarios. The README lists online throttled and unthrottled attacks, and offline slow and fast hashing, each with an assumed guess rate.
What people use it for
- A sign-up form that shows a live strength bar as the user types a password
- A password reset page that rejects passwords with score 0 or 1
- A server-side check in Node.js that scores passwords before storing a change
- A team replacing strict composition rules with a single minimum score
- A port in another language, such as zxcvbn-python or zxcvbn-rs, for a non-JavaScript backend
Frequently asked questions
How do I install zxcvbn?
The README gives npm install zxcvbn for Node.js projects. Bower and manual installation with dist/zxcvbn.js are also documented. Node.js is the prerequisite for the npm method.
Is zxcvbn free to use?
zxcvbn is released under the MIT licence, as listed on its repository. Check the LICENSE file in the repository for the full terms before you use it in your project.
What does the zxcvbn score mean?
The score is an integer from 0 to 4. The README defines 0 as too guessable and 4 as very unguessable, with 3 meaning safely unguessable against a slow-hash offline attack.
Can zxcvbn run on a server as well as in the browser?
Yes. The README says zxcvbn works identically on the server and can be required in Node.js. It also runs in the browser through a script tag or a module loader.
Why is zxcvbn large, and how do I keep pages fast?
The README says the minified and gzipped bundle is still several hundred kilobytes. Load it only on pages where passwords are entered, and fetch it after the page renders, since the check runs in response to user input.
Are there alternatives to zxcvbn?
The source lists comparable projects including zxcvbn-python, zxcvbn4j, nbvcxz and zxcvbn-rs. Choose one that matches your language, and check its own documentation for how it compares.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
zxcvbn suits developers who want a JavaScript or Node.js password strength meter for sign-up and reset forms, and teams moving away from strict composition rules. It is a library, not a finished app, and its results are estimates, so it should not replace server-side protections. If you need a ready-made application or a very small script, pick a different tool.
Install options & downloads