check-password-strength vs owasp-password-strength-test vs password-validator vs zxcvbn
Password Strength Validation Libraries in JavaScript
check-password-strengthowasp-password-strength-testpassword-validatorzxcvbnSimilar Packages:

Password Strength Validation Libraries in JavaScript

check-password-strength, owasp-password-strength-test, password-validator, and zxcvbn are JavaScript libraries used to evaluate password security, but they approach the problem differently. zxcvbn is the industry standard for entropy-based estimation, analyzing patterns and dictionary matches rather than simple rules. password-validator focuses on schema-based validation, allowing developers to define specific requirements like length and character types. check-password-strength offers a lightweight scoring system based on regex patterns. owasp-password-strength-test is an older implementation based on legacy OWASP guidelines, often considered outdated compared to modern entropy checks.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
check-password-strength019014.4 kB12 years agoMIT
owasp-password-strength-test0246-1111 years agoMIT
password-validator028235.8 kB7-MIT
zxcvbn016,026-14510 years agoMIT

Password Strength Validation: zxcvbn vs password-validator vs check-password-strength vs owasp-password-strength-test

Securing user accounts starts with strong password policies, but not all validation libraries measure strength the same way. Some check for rules like "must have a symbol," while others estimate how long it would take to crack the password. Let's compare how zxcvbn, password-validator, check-password-strength, and owasp-password-strength-test handle this critical task.

🧠 Core Logic: Entropy vs Rules

The biggest difference lies in how these libraries calculate strength. zxcvbn uses entropy estimation, meaning it looks for patterns, dictionary words, and common substitutions. The other three primarily rely on regex rules and constraints.

zxcvbn analyzes the password against a large dictionary and common patterns.

  • It guesses how many attempts an attacker would need.
  • It returns a score from 0 to 4 based on crack time.
import zxcvbn from 'zxcvbn';

const result = zxcvbn('correct horse battery staple');
console.log(result.score); // 4
console.log(result.guesses); // 15000000000

password-validator checks against a schema you define.

  • You set rules like minimum length or required character types.
  • It returns true or false, plus a list of failed requirements.
import PasswordValidator from 'password-validator';

const schema = new PasswordValidator();
schema
  .is().min(8)
  .is().max(100)
  .has().uppercase()
  .has().lowercase()
  .has().digits();

const isValid = schema.validate('MyPass1');
console.log(isValid); // true

check-password-strength uses a weighted regex system.

  • It assigns points for length, numbers, and symbols.
  • It returns a simple score and a classification like "Strong".
import { checkPasswordStrength } from 'check-password-strength';

const result = checkPasswordStrength('MyPass1');
console.log(result.value); // "Strong"
console.log(result.score); // 3

owasp-password-strength-test applies static OWASP rules.

  • It checks for length and character variety based on older standards.
  • It returns a score and feedback on what is missing.
import owasp from 'owasp-password-strength-test';

const result = owasp.test('MyPass1');
console.log(result.score); // 2
console.log(result.errors); // ["password is too short"]

🛠️ Customization and Configuration

Flexibility matters when your security policy changes. Some libraries let you tweak the algorithm, while others let you tweak the rules.

zxcvbn allows you to add custom dictionaries.

  • Useful if you want to block company names or specific terms.
  • You cannot change the core entropy algorithm easily.
import zxcvbn from 'zxcvbn';

// Adding custom dictionary
const result = zxcvbn('password', ['companyname']);
// Score will drop because 'companyname' is now known

password-validator is fully configurable via chaining.

  • You can add custom regex rules easily.
  • Ideal for adapting to changing compliance requirements.
import PasswordValidator from 'password-validator';

const schema = new PasswordValidator();
schema
  .is().min(8)
  .has().not().spaces()
  .has().uppercase()
  .has().symbols();

check-password-strength has limited configuration.

  • Most versions use a fixed set of regex patterns.
  • Some forks allow extending the dictionary, but core options are sparse.
import { checkPasswordStrength } from 'check-password-strength';

// Basic usage without deep config
const result = checkPasswordStrength('123456');

owasp-password-strength-test allows rule configuration.

  • You can set minimum lengths and character requirements.
  • However, the underlying logic is static and older.
import owasp from 'owasp-password-strength-test';

owasp.config({
  allowPassphrases: true,
  minLength: 10,
  maxLength: 128
});

📝 Feedback and User Experience

Good validation helps users create better passwords without frustration. The quality of feedback varies significantly between these tools.

zxcvbn provides specific warnings.

  • It tells users "Add another word" or "Avoid repeated characters".
  • This educates users on why a password is weak.
const result = zxcvbn('password123');
console.log(result.feedback.warning); // "This is a top-10 common password"
console.log(result.feedback.suggestions); // ["Add another word or two"]

password-validator returns validation errors.

  • You get a list of rules that failed.
  • You must map these errors to user-friendly messages yourself.
const errors = schema.validate('short', { list: true });
console.log(errors); // ["min"]
// You must convert "min" to "Password is too short"

check-password-strength gives a simple label.

  • Returns "Too weak", "Weak", "Medium", "Strong".
  • Less detailed than zxcvbn but easier to display quickly.
const result = checkPasswordStrength('abc');
console.log(result.value); // "Too weak"

owasp-password-strength-test lists missing requirements.

  • Provides an array of errors like "no digits".
  • Useful for checklist-style UI feedback.
const result = owasp.test('abc');
console.log(result.errors); // ["requires digits", "requires symbols"]

⚠️ Maintenance and Security Status

Security libraries must be kept up to date to remain effective. Some of these packages are no longer actively maintained.

zxcvbn is maintained by the community.

  • Originally built by Dropbox, now widely adopted.
  • Considered the gold standard for client-side strength checking.

password-validator is actively maintained.

  • Regular updates and good npm health.
  • Safe to use for rule-based validation.

check-password-strength has multiple variants.

  • Ensure you pick the most downloaded and recent fork.
  • Some versions are wrappers around other logic.

owasp-password-strength-test is largely unmaintained.

  • Last significant updates were years ago.
  • OWASP itself now recommends zxcvbn over this tool.
  • Do not use for new high-security applications.

🌐 Real-World Scenarios

Scenario 1: High-Security Fintech App

You need to ensure passwords resist brute-force and dictionary attacks.

  • Best choice: zxcvbn
  • Why? Entropy checking prevents common patterns that rules miss.
// Reject anything below score 3
if (zxcvbn(password).score < 3) {
  throw new Error('Password too guessable');
}

Scenario 2: Corporate Compliance Portal

Your policy requires exactly 12 characters, 1 symbol, and no spaces.

  • Best choice: password-validator
  • Why? You can encode exact policy rules into the schema.
schema.is().min(12).has().symbols().has().not().spaces();

Scenario 3: Simple Internal Dashboard

You just need to prevent users from setting "123456".

  • Best choice: check-password-strength
  • Why? Lightweight and easy to integrate for basic protection.
if (checkPasswordStrength(password).score === 0) {
  showError('Please choose a stronger password');
}

Scenario 4: Legacy System Migration

You are updating an old system that used OWASP standards in 2015.

  • Best choice: owasp-password-strength-test (Temporary)
  • Why? Only use to match existing legacy behavior during migration.
  • ⚠️ Plan to migrate to zxcvbn ASAP.
// Only for legacy compatibility
const result = owasp.test(password);

📊 Summary Table

Featurezxcvbnpassword-validatorcheck-password-strengthowasp-password-strength-test
LogicEntropy & PatternsSchema RulesRegex ScoringStatic Rules
ConfigurabilityCustom DictionariesFull Schema ControlLimitedModerate
FeedbackDetailed SuggestionsRule ErrorsSimple LabelsRequirement List
MaintenanceActive CommunityActiveVariedUnmaintained
Best ForSecurity CriticalComplianceSimple AppsLegacy Support

💡 Final Recommendation

For most modern applications, zxcvbn is the superior choice because it measures actual guessability rather than arbitrary rules. A password like Tr0ub4dor&3 looks strong by rules but is weak by entropy — zxcvbn catches this, while the others might not.

Use password-validator when you have strict regulatory requirements that demand specific character types. It gives you full control over the policy definition.

Avoid owasp-password-strength-test for new development. It represents an older era of password security that focused on complexity rather than length and unpredictability.

Final Thought: Password validation should happen on the server too. Client-side libraries improve UX, but never trust them for actual security enforcement.

How to Choose: check-password-strength vs owasp-password-strength-test vs password-validator vs zxcvbn

  • check-password-strength:

    Choose check-password-strength if you need a simple, lightweight scoring mechanism without the overhead of a large dictionary. It works well for smaller projects or internal tools where basic regex validation is sufficient. Use this when you want a quick score indicator without complex configuration.

  • owasp-password-strength-test:

    Avoid owasp-password-strength-test for new projects as it is largely unmaintained and based on outdated guidelines. Modern security practices favor entropy-based checks over the static rules this package enforces. Only consider this if you are maintaining a legacy system that specifically depends on its original test suite.

  • password-validator:

    Choose password-validator if your project requires strict compliance with specific policy rules, such as corporate security standards. It excels when you need to enforce exact constraints like minimum length, specific symbol counts, or forbidden characters. This package is ideal for forms where you must show specific error messages for each failed rule.

  • zxcvbn:

    Choose zxcvbn if you need the most accurate security assessment based on entropy and real-world cracking data. It is the best choice for applications where security is critical, as it detects patterns like 'password123' that regex miss. Use this when you want to guide users toward genuinely hard-to-guess passwords rather than just meeting arbitrary rules.

README for check-password-strength

Overview

A simple way to check that password strength of a certain passphrase. The library is fully typed.

Build status

npm Downloads

DEMO 1 by @Ennoriel

DEMO 2

Installation

Install via Package Manager

npm i check-password-strength --save

Install via Browser Script Tag using UNPKG

<script src="https://unpkg.com/check-password-strength/dist/umd.cjs"></script>
<script type="text/javascript">
    const passwordStrength = checkPasswordStrength.passwordStrength('pwd123').value; // 'Weak'
</script>

Setup & Basic Usage

const { passwordStrength } = require('check-password-strength')
// OR
import { passwordStrength } from 'check-password-strength'

console.log(passwordStrength('asdfasdf').value)
// Too weak (It will return Too weak if the value doesn't match the Weak conditions)

console.log(passwordStrength('asdf1234').value)
// Weak

console.log(passwordStrength('Asd1234!').value)
// Medium

console.log(passwordStrength('A@2asdF2020!!*').value)
// Strong

API

arguments

The passwordStrength takes 3 arguments:

  • password (string): the user password
  • options (array — optional): an option to override the default complexity required to match your password policy. See below.
  • restrictSymbolsTo (string — optional):
    • By default, the passwordStrength function checks against all characters except for the 26 Latin lowercase letters, 26 uppercase letters, and 10 digits. This includes OWASP-recommended characters, accented letters, other alphabets, and emojis.
    • If you wish to apply restrictions, you can provide a custom string. This string should consist of unescaped symbol characters, which will be utilized internally in a RegExp expression in the following format: [${escapeStringRegexp(restrictSymbolsTo)}].
    • Additionally, you can import and use the owaspSymbols to limit the symbols to those recommended by OWASP.

Password Default Options

The default options can be required:

const { defaultOptions } = require("./index");
// OR
import { defaultOptions } from 'check-password-strength'

default options:

[
  {
    id: 0,
    value: "Too weak",
    minDiversity: 0,
    minLength: 0
  },
  {
    id: 1,
    value: "Weak",
    minDiversity: 2,
    minLength: 8
  },
  {
    id: 2,
    value: "Medium",
    minDiversity: 4,
    minLength: 10
  },
  {
    id: 3,
    value: "Strong",
    minDiversity: 4,
    minLength: 12
  }
]

To override the default options, simply pass your custom array as the second argument:

  • id: correspond to the return id attribute.
  • value: correspond to the return value attribute.
  • minDiversity: between 0 and 4, correspond to the minimum of different criterias ('lowercase', 'uppercase', 'symbol', 'number') that should be met to pass the password strength
  • minLength: minimum length of the password that should be met to pass the password strength

You can use an array containing fewer or more than four items to define the levels of trust. However, the first element must have both the minDiversity and minLength parameters set to 0. This means that the first element should always represent a "too weak" option.

Result

The result is an object containing the following values (unless you override the options):

PropertyDesc.
id0 = Too weak, 1 = Weak & 2 = Medium, 3 = Strong
valueToo weak, Weak, Medium & Strong
containslowercase, uppercase, number and / or symbol
lengthlength of the password

If you want to translate the value (Too weak → Trop faible), you can translate it based on the return value, or override the defaultOptions option, which will be passed back as the function's return value.

Contribute

Feel free to clone or fork this project: https://github.com/deanilvincent/check-password-strength.git

Contributions & pull requests are welcome!

I'll be glad if you give this project a ★ on Github :)

changelog

  • v3: allow all symbols by default (any character except the 26 latin lowercase, uppercase letters and 10 digits) & set the default min length to 12 instead of 10
  • v2: allow configuration through options object
  • v1: first version

Kudos to @Ennoriel and his efforts for making v2 and v3 possible!