Home / Forms and Input / Password Strength Meter

Password Strength Meter in JavaScript, Free with Live Demo

Free password strength meter in plain JavaScript. Live score, checklist, common password check, estimated crack time, show and hide button and a secure password generator.

Open live demoDownload HTML fileView code on GitHub
Password Strength Meter JavaScript project: a password box that rates strength, estimates crack time and suggests a strong password

Runs on: crypto.getRandomValues. Works in all modern browsers.

What is the Password Strength Meter?

A password field with a four part strength meter, a live checklist and a short tip about what would make it stronger.

It spots common passwords even with swapped letters like p@ssw0rd, estimates how long an offline attack would take and can suggest a random password or a four word passphrase.

Good for

  • Sign up and change password forms
  • Admin and staff account setup
  • Password managers and vaults
  • Security awareness training

What this project does

How it works

  1. Check the basicsSimple tests look for length, lower and upper case letters, numbers and symbols, and tick the checklist live.
  2. Estimate real strengthLength times the size of the character pool gives bits of entropy. Repeats, sequences, years and common words lower the score.
  3. Generate safelyThe generator uses crypto.getRandomValues, not Math.random, so suggested passwords are truly unpredictable.

The key JavaScript

This is the heart of the project. The full file has the rest, including the screen layout and error handling.

function entropy(p) {
  const pool = (/[a-z]/.test(p) ? 26 : 0) + (/[A-Z]/.test(p) ? 26 : 0)
             + (/\d/.test(p) ? 10 : 0) + (/[^A-Za-z0-9]/.test(p) ? 32 : 0);
  return p.length * Math.log2(pool || 1);      // bits
}
function randomIndex(n) {
  const a = new Uint32Array(1);
  crypto.getRandomValues(a);                    // secure, unlike Math.random
  return a[0] % n;
}

How to use it

  1. Click Download HTML file above.
  2. Open the file in a code editor, like VS Code.
  3. Run it from a local server with npx serve . so the camera, microphone and AI features are allowed.
  4. Change the text and colors, then upload it to GitHub Pages, Netlify or your own site. It is one file with no build step.

Questions people ask

Is the password sent anywhere?

No. All checks run in your browser and nothing is stored.

Why do long passwords score so well?

Each extra character multiplies the number of guesses needed. Length matters more than symbols.

Should I block weak passwords?

It is a good idea to block the very weak level and common passwords, and allow the rest with a warning.

More Forms and Input projects