Skip to content
MC Command Generator

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.

#1Keep inventory · Java 1.21.11 and later (26.x)Epic

The current snake_case name. Players keep their items and XP when they die.

gamerule keep_inventory true
Open in /gamerule Java 26.3
#2Keep inventory · Java 1.4.2 – 1.21.10Rare

The camelCase name most videos and tutorials show.

gamerule keepInventory true
Open in /gamerule Java 1.21.9 – 1.21.10
#3Keep inventory · BedrockRare

Bedrock writes game rules in lowercase.

gamerule keepinventory true
Open in /gamerule Bedrock 26.50+

Why 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:

#4Turn keep inventory off · Java 1.21.11+Rare

Back to the default: items drop where you die.

gamerule keep_inventory false
Open in /gamerule Java 26.3

Still 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.