4-Digit Random Number Generator with Rules
Create one or many four-digit numbers and control exactly which digits are allowed. Results are generated locally in your browser.
Generation rules
Each entered digit must appear at least once.
Excluded digits will never appear in a result.
Generate between 1 and 100 results.
Generated numbers
Select any result to copy it.
How the 4-digit rules work
Leading zero allowed
When enabled, the output is a fixed-width four-digit code from 0000 through 9999. When disabled, the first digit must be 1–9, so every result is a four-digit integer from 1000 through 9999.
Repeated digits
Enable repeats for results such as 1107 or 5555. Disable repeats when every position must contain a different digit, such as 5831. If repeats are blocked, required digits must also be different.
Required and excluded digits
Use required digits when every result must contain particular values. For example, entering 37 means both 3 and 7 must appear somewhere. Excluded digits are removed from the available pool. The generator warns you when rules conflict or leave too few possible results.
Randomness and PIN safety
The tool uses the browser's cryptographic random-number source when available and avoids modulo bias when choosing digits. It is useful for games, classroom activities, test data, drawings, placeholders, and code examples. Do not use a public generator to choose a real banking PIN, device passcode, recovery code, or other security credential.