
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
luhn-generator
Advanced tools
A generator of numbers that passes the validation of Luhn algorithm or Luhn formula, also known as the 'modulus 10' or 'mod 10' algorithm
A generator of numbers that passes the validation of Luhn algorithm or Luhn formula, also known as the "modulus 10" or "mod 10" algorithm
npm install luhn-generator --save
import luhn from '../dist/luhn';
luhn.generate(1, { pad: 12 }); // 000000000018
$ node
> const luhn = require('../dist/luhn');
> luhn.generate(1, { pad: 12 }); // 000000000018
<!-- amd.html -->
<html>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.5/require.min.js"></script>
<script>
window.requirejs(['dist/luhn.min'], function(luhn) {
console.log(luhn.generate(1, { pad: 12 })); // 000000000018
});
</script>
</body>
</html>
<!-- script-tag.html -->
<html>
<body>
<script src="./dist/luhn.min.js"></script>
<script>
console.log(luhn.generate(1, { pad: 12 })); // 000000000018
</script>
</body>
</html>
Generate Luhn "check digit" for number 1:
luhn.checksum(1); // 8
luhn.checksum(12); // 5
Generate number that will pass Luhn algorithm validation:
luhn.generate(1); // 18
luhn.generate(12); // 125
luhn.generate(1, { pad: 5 }); // 00018
Generate random number that will pass Luhn algorithm validation:
luhn.random(12); // 6436204626980
luhn.random(50); // 54833184596638864915195736286128781213916608803535
luhn.random(12, { pad: 50 }); // 00000000000000000000000000000000000004591785326079
Validate number with Luhn algorithm:
luhn.validate(1); // false
luhn.validate(18); // true
luhn.validate(125); // true
FAQs
A generator of numbers that passes the validation of Luhn algorithm or Luhn formula, also known as the 'modulus 10' or 'mod 10' algorithm
The npm package luhn-generator receives a total of 2,235 weekly downloads. As such, luhn-generator popularity was classified as popular.
We found that luhn-generator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.