Keep inventory command: the right spelling for your version
GuideJava 1.4.2 → 26.3 · Bedrock4 min read4 commands
Turn on keep inventory with /gamerule: keep_inventory on Java 1.21.11+, keepInventory on older Java, keepinventory on Bedrock. Realms, servers and fixes.
The keep inventory command is /gamerule keep_inventory true on Java 1.21.11 and later (all 26.x versions), /gamerule keepInventory true on Java 1.21.10 and older, and /gamerule keepinventory true on Bedrock. Run it once and every player in the world keeps their items and experience when they die.
The current snake_case name. Players keep their items and XP when they die.
gamerule keep_inventory trueThe camelCase name most videos and tutorials show.
gamerule keepInventory trueBedrock writes game rules in lowercase.
gamerule keepinventory trueWhy it says “unknown game rule” or “incorrect argument”
Java 1.21.11 renamed every game rule to snake_case, so keepInventory is no longer accepted there, and keep_inventory is not accepted on 1.21.10 and older. Check your version on the title screen and use the matching line above. Bedrock accepts its lowercase name only. The /gamerule generator writes the right spelling for whichever version you pick.
Where you can run it
- Single player (Java): commands need cheats. Turn on Allow Cheats when you create the world, or open the world to LAN with cheats on for that session.
- Single player (Bedrock): turn on Cheats in the world settings, or switch on Keep Inventory in the Cheats section of the same screen; it is the same game rule.
- Servers and Realms: you must be an operator. On a Java server, run it from the server console, or as an op in chat. Bedrock Realms have the Keep Inventory switch in the world settings.
It is one setting for the whole world
A game rule belongs to the world, not to a player, so it covers every player and every dimension. You cannot turn keep inventory on for one player with vanilla commands. To check the current value, run the command without true or false, for example /gamerule keep_inventory. To turn it off again:
Back to the default: items drop where you die.
gamerule keep_inventory falseStill dropping items?
- The command ran in a different world: on a server with several worlds, a plugin may keep a separate setting per world.
- A plugin or data pack resets the rule or handles deaths itself. Check its settings.
- You typed it in a command block that is disabled on the server (enable-command-block in server.properties).
More rules, such as daylight cycle, mob griefing and fire spread, are in the gamerule generator, which lists every rule with its name for each version.
More drops
- Update drop3 commands/effect with tags: one command for a whole set of effects (26.4 snapshot)Four effects from one line, and the tag file you have to write first.Java 26.4 Snapshot 10 · 26.3
- Guide5 commandsHow to get a command block in Minecraft, and why it does nothingOne /give gets the block. A game rule decides whether it ever runs.Java 1.13 → 26.3 · Bedrock
- Next drop · 32,768 is the wall. One game rule moves it; here is the name for your version.Java 1.19.2 → 26.3 · 4 commands