
To turn on keep inventory in Minecraft Java Edition 1.21.11 and newer (26.3 is the current release), type /gamerule keep_inventory true. On Java 1.21.10 and older the command is /gamerule keepInventory true, and on Bedrock Edition it is /gamerule keepinventory true.
You need operator rights or cheats to run it. In a server console you type the same command without the slash, for example gamerule keep_inventory true, and the setting stays in that world until you set it back to false.
The keep inventory command for each version
| Edition and version | Turn it on | Turn it off |
|---|---|---|
| Java 1.21.11, 26.1, 26.2, 26.3 | /gamerule keep_inventory true | /gamerule keep_inventory false |
| Java 1.21.10 and older | /gamerule keepInventory true | /gamerule keepInventory false |
| Bedrock Edition | /gamerule keepinventory true | /gamerule keepinventory false |
The Java name changed in 1.21.11, released on December 9, 2025. Mojang moved all game rules into a registry, and with that every rule was renamed from camel case to a snake case ID, so keepInventory became keep_inventory (Java Edition 1.21.11 changelog, Game rule history). The 26.1, 26.2 and 26.3 drops kept that name. The full ID is minecraft:keep_inventory, but the short form is what the wiki uses in its examples.
Two details trip people up:
- Java arguments are case sensitive (gamerule command). On 1.21.11 and newer,
keepInventoryis no longer a rule name, so the command fails. On 1.21.10 and older,keepinventoryin lower case fails. - Bedrock accepts any capitalisation when you type it, so
keepInventoryandkeepinventoryboth work there.
To check the current value, leave the value off: /gamerule keep_inventory prints true or false.
What keep inventory keeps
With the rule set to true, you keep your items and your experience when you die. Health and hunger still reset, all status effects are still removed, and items with Curse of Vanishing do not disappear (Game rule). The default value is false in both editions.
Running it in game
Java single player. For the command, cheats have to be on. You turn them on with "Allow Commands" when you create the world, and the same Create World screen has an Edit Game Rules menu with a Keep Inventory toggle (Game rule). Since 26.1 the pause menu has a World Options screen where you can switch cheats and open the game rules list without typing anything (Commands, Java Edition 26.1). On older versions, "Open to LAN" with cheats allowed works as a temporary switch until you leave the world.
Java multiplayer. /gamerule needs permission level 2, so you have to be an operator (Permission level). Someone with console access runs op YourName first. Our OP commands guide explains the levels.
Bedrock. Keep Inventory sits in the Cheats section of the world settings, so you can flip the toggle there or use the command with cheats on. Turning cheats on permanently blocks achievements in that world, even if you switch them off later (Commands). The command itself needs operator status (gamerule command).
Running it from a server console
Commands typed into a server console have no leading slash (Commands). For a Java server on 1.21.11 or newer:
gamerule keep_inventory true
For a Java server on 1.21.10 or older:
gamerule keepInventory true
For a Bedrock Dedicated Server:
gamerule keepinventory true
On Bedrock, keep inventory counts as a cheat setting, so cheats must be allowed on the server. Set allow-cheats=true in server.properties, or run changesetting allow-cheats true in the console, which changes it while the server runs but does not write it to the file (server.properties, changesetting).
Where the setting is stored
Game rules belong to a world, not to the server or to a player. Since Java 26.1 they live in data/minecraft/game_rules.dat inside the world folder. Before 26.1 they were stored in level.dat (Java Edition level format).
That has a few practical effects:
- The setting survives restarts. You set it once.
- If you copy or upload the world folder, keep inventory comes with it.
- A fresh world, a world reset or a different
level-nameinserver.propertiesstarts atfalseagain. - On a vanilla server one world folder holds the Overworld, the Nether and the End, so one command covers all three.
Multiple worlds: Paper, Spigot and Multiverse
Bukkit based servers (Spigot, Paper, Purpur) keep game rules per world, and the Nether and the End are separate worlds there. A Spigot bug report about game rules only applying in the Overworld was closed as invalid, because that is how it is designed (SPIGOT-4971). Paper 26.1 moved its dimension folders closer to vanilla but kept per-world game rules (PaperMC 26.1 notes).
So if you set keep inventory in the Overworld and still lose your items in the Nether, that is why. Run the command once while standing in each dimension, or set them all from the console. A plain console command changes the main world, and execute in points it at the other two:
gamerule keep_inventory true
execute in minecraft:the_nether run gamerule keep_inventory true
execute in minecraft:the_end run gamerule keep_inventory true
On 1.21.10 and older, use keepInventory in these three lines.
With Multiverse-Core 5, every extra world has its own value. Set one with /mv gamerule set <rule> <value> [world] and check it with /mv gamerule list [world] (Multiverse-Core commands). Use the rule name that your server version expects; tab completion shows it.
Keep inventory on Realms
Java Realms. The Realm owner is always an operator. To give another player operator status, the owner quits to the main menu and opens the Realm's configuration screen (Realms). Realms run the latest release, so use /gamerule keep_inventory true.
Bedrock Realms. The owner or an operator can turn on Keep Inventory in the world settings under Cheats, from the game menu while playing, or run /gamerule keepinventory true with cheats on. As in single player, achievements stay off for that world afterwards.
Why keep inventory does not work
- Wrong name for your version.
keepInventoryfails on 1.21.11 and newer,keep_inventoryfails on 1.21.10 and older, and lower casekeepinventoryonly works on Bedrock. - No permission. Without operator status or cheats the command is rejected, and Java shows it as an unknown command. Ask someone with console access to run
op YourName, or turn cheats on in single player. - Wrong world. You set it in your single player world instead of on the server, or only in the Overworld on a Paper server, or in another Multiverse world. Run
/gamerule keep_inventorywhere you died to see the real value. - A command block or data pack turns it off. Minigame maps and some data packs set game rules in a repeating command block or a function. If the value keeps flipping back to
false, look forgamerulein your command blocks and in thedatapacksfolder. Data packs written for the oldkeepInventoryname throw errors on 1.21.11 and newer. - A plugin or mod handles deaths. Paper's API lets a plugin decide per death whether items are kept (PlayerDeathEvent), and EssentialsX has an
essentials.keepinvpermission that controls whether a player keeps their inventory on death (EssentialsX plugin.yml). Grave and death chest mods also change what happens to items. Test a death after you install one. - You died before turning it on. The rule only affects deaths after you set it. Items already on the ground are not returned to you.
Turning on keep inventory on your own server
On a server with a Pterodactyl panel you do not have to join the game at all. Open the Console tab, type gamerule keep_inventory true without the slash (or keepInventory on 1.21.10 and older) and press Enter. The panel shows the server's reply, and because the value is saved in the world, it is still on after the next restart. On Paper, add the two execute in lines above for the Nether and the End. Space-Node's Minecraft server hosting runs on that panel, with Standard plans from €2.70 a month for 3 GB of RAM.
FAQ
Does keep inventory also keep my XP? Yes. With the rule on, you keep both your items and your experience levels.
Can I turn on keep inventory for one player only?
Not with the game rule, which applies to everyone in that world. On a Paper server a plugin can do it per player, for example with the essentials.keepinv permission in EssentialsX.
Do I have to run the command again after a restart? No. The value is stored in the world files and stays until you change it.
Related: Minecraft OP commands guide, Minecraft server commands cheatsheet