/gamerule Command
Queries or changes a game rule. Boolean rules accept true/false; integer rules accept a non-negative integer. Omitting the value prints the current value of the rule. Rules cover gameplay mechanics including mob spawning, item drops, day-night cycle, fire spread, PvP, and more.
Syntax
/gamerule <rule> [<value>]Permission: 2Edition: Both
Examples
/gamerule keepInventory true/gamerule doDaylightCycle false/gamerule randomTickSpeed 10/gamerule doMobSpawning falseNotes
Java 1.21 notable rules include playersSleepingPercentage (0–100), freezeDamage, doWardenSpawning, and globalSoundEvents. Java Edition uses camelCase rule names (e.g. keepInventory); Bedrock also uses camelCase but has a different superset of available rules. Querying (no value) requires no special permission in singleplayer.