Discord
Command block from Minecraft, icon for the keep inventory guide
Wiki / Commands

Keep Inventory: the keep_inventory and keepInventory commands

Keep inventory is a game rule that lets you keep all your items and experience after you die. It's off by default: your inventory drops on the ground and you have 5 minutes to pick it up before it disappears. In Java 1.21.11 and newer the rule is called keep_inventory, in older Java versions keepInventory, and in Bedrock Edition keepinventory.

The command in every version

Java Edition 1.21.11 and newer, including all 26.x versions. In 1.21.11 Mojang renamed the game rules to snake_case:

/gamerule keep_inventory true

Java Edition 1.21.10 and older:

/gamerule keepInventory true

Bedrock Edition (phones, consoles, Windows):

/gamerule keepinventory true

In Java Edition capitalization matters, so type the name exactly as shown above. Bedrock doesn't distinguish between uppercase and lowercase: keepinventory and keepInventory work the same. If you're not sure which name to use in Java, start typing /gamerule keep and press Tab, and the game suggests the name for your version.

Running the command with no value, for example /gamerule keep_inventory, shows the current setting. You'll find the full list of game rules and their old names on our /gamerule command page.

How to turn it on

Java: new world, no commands

Select Singleplayer, then Create New World, go to the More tab and click Game Rules. In the Player category, turn on Keep inventory after death. Game rules set during world creation work even when commands are disabled.

Java: existing world

Open chat with T (or /) and type the command for your version. The command requires commands to be enabled, and how you enable them depends on the version:

  • Java 26.3 and newer: press Esc and click World Options.... In the General section, turn on Allow Commands. The same screen has an Edit Game Rules... button, where you can toggle Keep inventory after death without typing a command.
  • Java 26.2: press Esc, go to Options..., then World Options..., and turn on Allow Commands. In this version, the commands switch on the world sharing screen for LAN only applies to other players.
  • Java 26.1 and older: press Esc, click Open to LAN, turn on Allow Cheats and click Start LAN World. Commands work until you close the world. In 26.1 the game rules screen is already in the game: Options..., World Options..., Edit Game Rules....

The in-game game rules screen is only available to operators, so turn commands on first. We walk through each version step by step in our guide to enabling cheats.

In Bedrock Edition

The command works the same way, but you can also use a toggle. In the world settings (when creating a world, when editing it, or in the settings from the pause menu), open the Cheats section, turn on Activate Cheats and switch on Keep Inventory. The Keep Inventory toggle only becomes available after cheats are activated, and enabling cheats permanently disables achievements in that world, even if you turn cheats off afterward.

On a server

You need operator permissions: level 2 in Java Edition and level 1 in Bedrock Edition. Type the command in the in-game chat or in the server console. The change applies immediately and persists after a server restart.

Where the setting is stored

Game rules are part of the world save. In Java 26.1 and newer they go into the data/minecraft/game_rules.dat file in the world folder, and in older versions into level.dat. Once set, the rule stays in effect until you change it. It doesn't reset when you restart the game, restart the server or reopen the world.

How to turn it off

Enter /gamerule keep_inventory false (Java 1.21.11 and newer), /gamerule keepInventory false (older Java versions) or /gamerule keepinventory false (Bedrock). From that moment on, dying means losing your items and experience again. The change takes effect immediately: if you die a second after entering the command, your items will drop.

Vanilla has no partial keep inventory: you either keep everything or lose everything. More detailed rules (for example keeping XP while losing items) need a server plugin, for instance on the Paper or Spigot engine.

What exactly you keep

  • Your entire inventory: all 36 slots (hotbar and main inventory)
  • Armor: helmet, chestplate, leggings and boots stay equipped
  • Offhand item: shield, totem, map
  • Experience (XP): you don't lose experience points or levels

What you do NOT keep (because it isn't part of your inventory):

  • Position: you respawn at your bed, at a respawn anchor or at the world spawn, not where you died
  • Potion effects: active effects (Regeneration, Strength, Resistance) vanish on death regardless of keep inventory
  • Vehicles: if you were riding a horse or a boat, you're no longer on it after respawning

Multiplayer: things to consider

Keep inventory applies to ALL players on the server. In vanilla you can't enable it for one person and not for another. It's a world rule, not a player rule.

On PvP servers, keep inventory changes the game dramatically. Players aren't afraid of dying because they lose nothing. The risk and the reward both disappear: a player in good armor risks nothing, because even if you defeat them, they get their whole inventory back. That's why PvP servers usually leave this rule off.

It's different on building and creative servers. Players focus on building, not fighting. Losing your inventory after falling off scaffolding is just frustrating, and keep inventory solves that problem.

Compromise: Some servers keep your inventory only in certain zones (for example in town) and use the regular rules in the wilderness. That needs a plugin that supports regions with their own rules.

When to use it

  • Building big projects: when you're carrying materials worth hours of farming, and a single fall from a height could cost you all of it
  • Playing with kids: younger players get upset about losing items. Keep inventory lets them play without stress
  • Exploring the Nether: items that fall into lava burn (except netherite items). With keep inventory nothing drops, so nothing burns
  • Testing and debugging: when you're checking adventure maps, redstone contraptions or boss fights
  • Casual servers: communities focused on relaxing, building and playing together without competition

When NOT to use it: on competitive survival servers and on PvP servers, because keep inventory takes the tension out of fights. In a hardcore world the game rules screen is disabled, and in Java 26.2 and newer you can't allow commands there from the menu. Keep inventory would defeat the point of that mode anyway.