
genkode — Random ID & String Generator for Node.js
Generating random strings comes up constantly in backend work — session tokens, invoice numbers, API keys, temporary codes, test data. Most of the time you end up copy-pasting the same Math.random().toString(36) snippet or reaching for a heavy library when you only need one function. I built genkode to fix that for myself, and after using it across a few projects I cleaned it up and published it. Zero dependencies, full TypeScript support, and a small focused API that handles the cases I kept running into. Here's what it does and how I built it. Installation npm install genkode The basics The main export is generateCode . At its simplest: import { generateCode } from ' genkode ' ; generateCode ({ length : 12 }); // → 'rqfvYxJRWfoP' (alpha by default) generateCode ({ length : 12 , type : " alphanumeric " }); // → 'aZ8kL2pQ9xW1' generateCode ({ length : 12 , type : " numeric " }); // → '362128126198' Three types: alpha , numeric , alphanumeric . That covers most cases without any configu
Continue reading on Dev.to
Opens in a new tab



