Generate 4 digit random number
To generate a 4 digit random number, set a four-digit range and a repeat rule, then draw. Ordinary speech often means 1000 through 9999, or 0000 through 9999 if leading zeros count.
How it works
Four digits is a length, not a mood. You still owe the tool two ends. If leading zeros are allowed, the closed range is 0000 through 9999: ten thousand strings. If you want a number that always prints four characters without a leading zero, the closed range is 1000 through 9999: nine thousand integers. Generate random 4 digit number searches are the same job with the words in another order. They do not change the arithmetic. They still need you to say which of those two ranges you meant.
Inclusive ends are the usual reading. 1000 counts in the no-leading-zero range. 9999 counts in both. 0999 is a four-digit string only if you pad zeros; as an integer it is 999, which is three digits. Write the rule before you click. A result of 742 is not a four-digit number unless you asked for padding. A result of 0742 is four digits only in a string mode.
Most page widgets are pseudorandom: hard to guess by eye, not built as a secret-key source. That is enough for a classroom pin, a game code, or a raffle among people who can see the draw. It is the wrong instrument for a bank password or a cryptographic nonce. Those jobs need a generator built for secrets. A four-digit classroom spinner is not that generator, even if it looks busy.
Range first, then the four digits
Decide padding, then decide repeats. A PIN-style draw from 0–9 taken four times with repeats allowed can produce 0000 and 9999 and everything between as digit strings. A single integer draw from 1000–9999 cannot produce 0042. Those are different tools that both answer “four digits” in casual speech. If two people must live with the result, say which tool you used in one sentence.
Say whether leading zeros count. Set the minimum and maximum to match that choice. Say whether a digit or a whole number may repeat when you draw more than one. Save the output with the range; a bare four-digit string is not a specification.
Independent draws may repeat. Two 4417s in a row can be honest. If you need unique codes, that is sampling without replacement from the range, then a take. A generator that secretly skips recent values is no longer uniform. Decide whether you wanted a die or a deck.
If you did not write the range, you did not generate a four-digit number. You generated a surprise and hoped it had four characters.
PINs, lists, and a record someone else can read
One number is a draw. A list is several draws or a shuffle. For a list of unique four-digit codes, shuffle the range and take as many as you need, up to the size of the range. You cannot take ten thousand unique values from 1000–9999; that range only holds nine thousand. The tool should refuse, or you should shrink the list. Silence from a page that prints duplicates after you asked for unique values is a bug in the setting, not in luck.
If you generate a 4 digit random number in front of a group, show the bounds, then the result. If you generate it in a chat, paste both. Fairness arguments start when nobody can say whether 0000 was legal. The generator cannot fix that after the fact. The saved line is the draw. Memory is not.
Do not sort the digits if the order is the code. Sorting 3921 into 1239 is a different number. Sort only when the job is a set, such as a lottery-style pick where order does not matter. Four-digit PINs care about order. Say so.
Questions and answers
- Does “generate 4 digit random number” include 0000?
- Only if leading zeros count. As an integer range, 1000–9999 excludes it. As a padded string, 0000–9999 includes it.
- Is generate random 4 digit number a different tool?
- No. It is the same request with the words shuffled. You still have to set the range.
- Can I use this for a password?
- Not if it is an ordinary widget and the secret matters. Four digits are a small space. Use a secret-grade generator and a longer secret.
Related guides
Address random generator
An address random generator builds a fake street line so you do not invent one by hand. Searches for random address generator, address generator random, and a New York variant still want a sample, not
Alphabet random generator
An alphabet random generator shuffles the letters of an alphabet into a new order. For English that is a permutation of A through Z, each letter once.
Animal generator random
An animal generator random pick is one animal name drawn from the tool’s list. Each click returns one animal from that list, not a living creature and not a complete catalog of Earth.