Keep inventory in Minecraft is a simple setting that stops you from losing your entire inventory every time you die. Whether you just fell into lava with a stack of diamonds or got ambushed near your base, this gamerule turns death from a disaster into a minor setback. This guide covers the exact command, how it works on both Java and Bedrock, and what to watch out for on newer versions.
TL;DR
- The command is /gamerule keepInventory true, typed into chat with cheats enabled.
- On Java Edition 1.21.11 and later, the command changed to /gamerule minecraft:keep_inventory true.
- Bedrock Edition singleplayer has a direct toggle in the Settings menu instead of typing a command.
- Enabling it preserves both your items and your XP after death.
- Cheats must be enabled, and multiplayer players need operator permissions to run the command.
- To turn it off again, run the same command with false instead of true.
What Keep Inventory Actually Does
By default, dying in Minecraft scatters your items around your death location and drops most of your XP. Those items despawn after 5 minutes of loaded time, so if you can’t get back to them fast, they’re gone for good. Enabling keepInventory changes this entirely: when you die, you respawn with your full inventory, armor, and experience level intact, as if nothing happened.

How to Enable Keep Inventory on Java Edition
Before you can run any gamerule command, cheats need to be enabled on your world. If you’re creating a new world, you can turn this on directly in the world creation menu under Game Rules. For an existing world without cheats already active, temporarily open it to LAN with cheats enabled to unlock command access.
Once cheats are active, open chat and type:
/gamerule keepInventory true
Press Enter, and you should see a confirmation message in chat. The command is case-sensitive, so make sure the capital “I” in Inventory is typed correctly, or it won’t register.
Important Change on Java 1.21.11 and Later
Starting with Java Edition 1.21.11, Mojang renamed all gamerules to a new snake_case format with a minecraft: prefix. On this version and newer, use:
/gamerule minecraft:keep_inventory true
The older /gamerule keepInventory true syntax may no longer be accepted on these versions. If you’re unsure which version you’re running, try the old command first, and switch to the new format if it returns an error.
How to Enable Keep Inventory on Bedrock Edition
Bedrock Edition makes this easier for singleplayer worlds. Open your world’s Settings menu, go to the Game category, and turn on Activate Cheats if it isn’t already. In the same menu, you’ll find a direct Keep Inventory toggle you can switch on without typing anything. For Bedrock servers, you’ll need to enable Allow Cheats in the server settings first, then run the same /gamerule keepInventory true command through chat once you have operator permissions.
Enabling Keep Inventory on a Multiplayer Server
On a server, you need operator status to change gamerules. Log into your server console or use op yourUsername if you have admin access, then join the server and run the command in chat. After enabling it, run /save-all to make sure the setting is written to disk, especially before restarting the server. Keep in mind this setting applies to every player on the server, not just you, so it’s worth letting others know before flipping it on or off. If you’re just getting a server running, our guide on how to make and join a Minecraft server covers the basics.
Turning Keep Inventory Off
If you want to go back to normal item-drop rules, run the same command with false instead:
/gamerule keepInventory false
Or on Java 1.21.11+, use /gamerule minecraft:keep_inventory false.
Common Issues
- Command not working: Double-check that cheats are enabled and that you have operator permissions on a server.
- Wrong capitalization: The command is case-sensitive on Java Edition, so keepinventory (all lowercase) will fail.
- Setting not saving: Run /save-all on Java servers after changing the rule, and restart Bedrock servers to apply changes properly.
- Using the old command on a new version: If you’re on Java 1.21.11 or later, switch to the minecraft:keep_inventory format.
Should You Use Keep Inventory?
This comes down to how you want to play. Keep inventory is great for relaxed building, testing risky jumps, or exploring dangerous areas like the Nether or the End without fear of losing your gear permanently. It’s less suited for players who want death to carry real stakes, particularly in Hardcore worlds where the challenge is part of the point. If you’d rather keep the risk but still want a safety net, carrying a totem of undying gives you a one-time save without changing the game’s rules for everyone.
Minecraft is available across platforms if you want to test this setting on the go. Grab it through the Google Play Store or the Xbox Store. For official patch notes and gamerule updates, check the official Minecraft website.
Frequently Asked Questions
What is the exact command to keep inventory in Minecraft?
Type /gamerule keepInventory true in chat with cheats enabled. On Java Edition 1.21.11 and later, use /gamerule minecraft:keep_inventory true instead.
Does keep inventory save my XP too?
Yes. Enabling keepInventory preserves both your items and your experience level after death, not just your inventory.
Can I use keep inventory in Hardcore mode?
Technically yes, since it’s just a gamerule, but it removes much of the intended risk of Hardcore worlds, so it’s generally not recommended there.
Why isn’t the keepInventory command working for me?
The most common causes are cheats being disabled or, on a server, not having operator permissions. Double-check both before trying again.
Can I make only certain players keep their inventory?
Not with vanilla gamerules, since the setting applies to everyone on the world or server. Per-player control requires third-party server plugins.



