/random Command
Generates a random integer within a range, or resets a named random sequence with a specific seed. `value` shows the result only to the command executor; `roll` broadcasts the result to all players. Named sequences (`<sequence>`) are deterministic when seeded and persist across reloads, enabling reproducible randomness in datapacks. `reset *` resets all sequences.
random (value|roll) <range> [<sequence>]
random reset (*|<sequence>) [<seed>] [<includeWorldSeed>] [<includeSequenceId>]Examples
random roll 1..6random value 1..100 mypack:loot_rollrandom reset mypack:loot_roll 12345 true trueexecute store result score @s dice_result run random value 1..20Notes
Exclusive to Java Edition. Added in Java Edition 1.20.2. `<range>` format is `<min>..<max>` (both inclusive); the span (max - min + 1) must be between 2 and 2,147,483,646. `<seed>` is a 32-bit integer salt. `includeWorldSeed` mixes the world seed into the sequence seed. `includeSequenceId` mixes the sequence resource location into the seed. The result can be captured with `execute store result score` for use in further logic.