How the Coupon Code Generator Builds Codes
AnyTool Coupon Code Generator creates promo, voucher and discount codes entirely in the browser using the Web Crypto API (secureRandomInt with rejection sampling, so character choice is uniform and free of modulo bias — never Math.random). It offers two modes. Simple mode takes a length and a character set (letters+digits, letters only, or digits only, or a custom set) and can split the body into fixed-length segments joined by a separator, for example SAVE-7F3K-9QH2. Pattern mode takes a template in which # is replaced by a digit, X or A by a letter, ? by a letter or digit, and * by your chosen character set, while every other character is copied literally — so SUMMER-####-2026 or GIFT-XXXX-#### keep their fixed text and randomise only the placeholders.
- Randomness from crypto.getRandomValues via secureRandomInt — no modulo bias
- Simple mode: length + character set, optional segment grouping
- Pattern mode: # digit, X/A letter, ? alphanumeric, * custom set, others literal
- Optional prefix, suffix, exclude look-alikes (O/0/I/1) and force-uppercase
- All generation is client-side JavaScript — no server round-trip
