Short answer: to keep every item in your inventory and all of your experience when you die in Minecraft Java Edition, run /gamerule keepInventory true. This turns on the built-in keepInventory game rule so nothing drops on the ground and no XP is lost on death. Changing it requires operator permission (cheats enabled), and the setting is stored per world.
This guide covers the exact syntax, copy-paste examples, the op level you need, what the rule does and does not reset, and how Java Edition differs from Bedrock. It is written for Minecraft Java Edition 26.2, where the command is unchanged from earlier versions. If you want to browse and tweak every rule interactively, use our free Minecraft Gamerule Browser tool.
Syntax
Keep Inventory is not a standalone command; it is a boolean rule set through the /gamerule command. The general form is:
/gamerule [value]
For keep-inventory specifically, the rule name is keepInventory and the value is true or false. If you omit the value, the command queries and prints the current setting instead of changing it.
| Argument | Required? | Accepted values | What it does |
|---|---|---|---|
keepInventory (rule name) | Yes | Exact, case-sensitive token | Selects the keep-inventory game rule. Must be typed in camelCase. |
[value] | No | true or false | true keeps items and XP on death; false is the vanilla default (items drop, XP lost). Omit it to query the current value. |
Two things to note. First, the name is case-sensitive: it must be keepInventory, not keepinventory or Keepinventory. Second, the internal registry ID is the snake_case keep_inventory, but you must not type that in chat — the command-facing name is the camelCase keepInventory. Since Java Edition 1.13, /gamerule rejects unknown rule names and type-checks values, so a boolean rule accepts only true or false.
Examples
Open the chat window with the T key, then type one of the following. Each is copy-paste ready.
1. Turn keep-inventory ON — the most common use. Players now respawn with everything they were carrying, plus their XP:
/gamerule keepInventory true
2. Turn keep-inventory OFF — reverts to vanilla behavior, where items drop on the ground and XP is lost on death:
/gamerule keepInventory false
3. Check the current setting — omit the value and the game prints whether the rule is currently true or false:
/gamerule keepInventory
4. Run it from a command block — inside a command block you drop the leading slash:
gamerule keepInventory true
5. Run it from a dedicated-server console — same as the command block, no slash needed. This is how server owners set it globally for a world:
gamerule keepInventory true
Prefer to set it before you ever spawn? When you create a new world in Java Edition, go to Create New World → More / Game Rules and toggle Keep inventory after death to ON, so the rule is active from the first spawn. (The exact toggle wording can vary slightly by version and language.)
Permissions, op level, and what still resets
Changing keepInventory in an existing world requires permission level 2 — operator status, or cheats enabled. In single-player that means your world was created with cheats on, or you used Open to LAN with Allow Cheats: ON. On a multiplayer server you need op, or you run it from the server console. Command blocks also run at the required permission level. The default value of the rule is false.
It is important to understand exactly what the rule protects. When keepInventory is true:
- Kept: all inventory items and armor, and your accumulated experience (XP). Nothing drops on the ground.
- Not affected: health and hunger are still reset on respawn, and all active status effects are still removed on death. Keep Inventory only stops item and XP loss.
- Curse of Vanishing: while
keepInventoryistrue, the Curse of Vanishing enchantment does not trigger — cursed items stay with you instead of being destroyed.
Game rules are stored per world. Setting keepInventory in one world does not carry it to any other world or save — you must set it separately in each one. This rule uses no item data components or NBT, so the 1.20.5 /give component-syntax change does not apply here. For the full catalog of rules, see our Minecraft gamerules list, and for every command in general, the Minecraft commands list.
Java vs Bedrock
The behavior is the same across editions — you keep both items and XP on death — but the way you set it differs.
| Java Edition | Bedrock Edition | |
|---|---|---|
| Command token | /gamerule keepInventory true (camelCase, case-sensitive) | /gamerule keepinventory true (lowercase) |
| Typical UI toggle | Create New World → Game Rules → Keep inventory after death | World Settings → Cheats → Keep Inventory switch |
| Requirement | Operator / permission level 2 (cheats) | Cheats enabled (host/operator) |
| Side effect | None on progression | Enabling cheats can disable achievements for that world |
In short: on Java, type keepInventory exactly; on Bedrock, use lowercase keepinventory or just flip the Keep Inventory switch in the world’s Cheats settings. Bedrock UI wording may vary by build. This article targets the Java Edition 26.2 release cycle.
FAQ
Does Keep Inventory also save my experience?
Yes. When keepInventory is true you keep both your items and your XP on death — no experience is lost. Health and hunger are still reset when you respawn, and status effects are still removed on death.
Why does my command say the rule is unknown?
Almost always a capitalization mistake. The name is case-sensitive and must be typed as keepInventory. Do not type the internal ID keep_inventory in chat, and do not use lowercase keepinventory (that is the Bedrock spelling). Since 1.13, Java rejects unknown rule names outright.
Why can’t I run the command at all?
You need permission level 2 (operator / cheats). In single-player, cheats must be enabled for the world, or open it to LAN with Allow Cheats: ON. On a server, you must be op or run it from the console.
Do I have to set it in every world?
Yes. Game rules are stored per world and do not transfer between saves, so enable keepInventory separately in each world — or toggle it on the Game Rules screen when creating a new world.
How do I get my items back if I forgot to enable it?
Keep Inventory is not retroactive — it only affects deaths that happen after you turn it on. If you already died with it off, you can re-obtain gear with the /give command (look up the right names in our Minecraft item IDs list) or return to your death location using teleport commands.
Want a hassle-free world where you control every rule? Spin up a server with XGamingServer Minecraft server hosting and set keepInventory straight from the console. For deeper dives, explore our full keep inventory command reference and related guides on the /summon command and target selectors — or jump straight into the Minecraft Gamerule Browser to configure every rule visually.
Ready to play?
Run your own Minecraft server with XGamingServer
Spin up an always-on Minecraft server your friends can join in minutes — no port-forwarding, no tech headaches.







