Minecraft · Wiki · Command

/clear

Clears items from a player's inventory.

TypeCommand

Data checked Oct 21, 2026

The /clear command removes items from a player’s inventory. It can wipe everything, remove only one item type, take away a set number of items, or simply count how many of an item a player carries. Map makers use it to reset players between rounds, servers use it to remove banned items, and adventure maps use it to take a key item when a door opens. This command reference covers the syntax in Java and Bedrock, filtering by item, counting items, examples and common errors.

Syntax

Edition Syntax
Java /clear [targets] [item] [maxCount]
Bedrock /clear [player] [itemName] [data] [maxCount]
  • targets or player (optional): whose inventory to clear. Leaving it out clears your own.
  • item (optional): only remove this item. In Java you can use an item tag such as #minecraft:logs, or add data components to match specific items.
  • data (Bedrock): the item’s data value, usually -1 to match any variant, or 0.
  • maxCount (optional): the most items to remove. Using 0 removes nothing and just reports how many the player has.

What /clear removes

/clear covers the whole player inventory: the main inventory, the hotbar, armor slots and the offhand slot. It also removes the item held on the cursor in some cases. It does not touch your ender chest, any chests in the world, or items on the ground. To remove dropped items, use /kill @e[type=item]; see the /kill reference.

Examples

Command Result
/clear Empties your entire inventory, including armor
/clear @a Empties every player’s inventory
/clear @s dirt Removes all dirt from your inventory
/clear @s cobblestone 64 Removes up to 64 cobblestone
/clear @s diamond 0 Removes nothing, reports how many diamonds you have
/clear @a #minecraft:logs Java: removes every type of log from everyone
/clear Steve ender_pearl Removes Steve’s ender pearls
/clear @p golden_key 1 Takes one custom key item from the nearest player

Counting items with maxCount 0

Setting maxCount to 0 is a clever trick: the command removes nothing but returns the number of matching items. In Java, combine it with /execute store or /execute if to check whether a player has enough of something, for example whether they collected ten emeralds before a door opens. Command block outputs and comparators can read the result, which lets map makers build shops, quest checks and puzzle locks without plugins.

Practical uses

  • Minigame resets: clear every player at the start of a round, then hand out a kit with /give.
  • Key items: take a key when the player uses it on a door, so it cannot be reused.
  • Shops: remove emeralds or currency items and give a reward in exchange.
  • Banned items: servers can remove items they do not allow, such as TNT on a building server.
  • Inventory cleanup: quickly get rid of junk such as dirt, cobblestone, gravel and rotten flesh after a mining trip.
  • Testing: reset your own inventory in a creative test world.

Clearing junk after mining

After long mining sessions, inventories fill with cobblestone, deepslate, tuff, andesite, diorite, granite, dirt and gravel. In a world with cheats, running /clear @s for each junk block frees space instantly while keeping valuables. In Java, item tags make this faster; for example, /clear @s #minecraft:dirt removes several dirt variants at once. In Survival without cheats, keep a lava pit or a cactus near your base to dispose of junk, or store it for building.

Be careful with /clear

/clear permanently deletes items. There is no undo, and cleared items do not drop on the ground. Running /clear @a by mistake on a server removes every player’s gear, including enchanted netherite armor and tools. Always specify the target and item when you only want to remove something specific. On servers, staff should use /clear on themselves first to test a command before running it on others.

Permissions

/clear requires cheats or operator permission. In Bedrock, using commands disables achievements for that world.

Common errors

  • No items were found: the player does not have that item, or the name is misspelled.
  • Unknown item: wrong ID; use underscores, such as rotten_flesh.
  • Bedrock clears too little: the data value did not match; use -1 to match any variant.
  • Ender chest items remain: /clear does not touch ender chests; this is expected.

Related commands

  • /give: add items.
  • /kill: remove dropped items on the ground.
  • /item: replace or modify items in specific slots in Java.

/clear FAQ

How do you clear your inventory in Minecraft?

Type /clear with cheats enabled.

How do you clear one item type?

Add the item ID: /clear @s dirt.

Does /clear remove armor?

Yes. It clears armor and the offhand too.

Does /clear empty the ender chest?

No.

How do you count items with a command?

Use /clear with a maxCount of 0, which only reports the number.

/clear in adventure maps

Adventure maps rely on /clear to keep puzzles fair. At the start of a level, a command block clears each player’s inventory so nobody brings tools from earlier areas. When a player places a key in a lock, a command block runs /clear @p tripwire_hook 1 and opens the door, so the key is consumed. Shops use /clear with maxCount to remove a set price, for example ten emeralds, then use /give to hand out the reward. Combining /clear with a check that uses maxCount 0 first ensures the player actually has enough currency before anything is taken, which avoids players losing items without getting the reward.

Clearing specific custom items in Java

In Java, the item argument can include data components to match only items with a certain name or property. That lets map makers remove a custom item such as a sword named Quest Blade while leaving every other sword alone. It also lets servers remove one type of enchanted item without affecting plain versions. The exact component format depends on your Java version, so use the command suggestions while typing or a generator set to your version.

Clearing items from other players on servers

Server staff sometimes need to remove duplicated or illegal items. The safest approach is to target the player by name and specify the exact item, then use maxCount if only part of a stack should go. Document what was removed so the player can be compensated if it was a mistake. Avoid broad commands such as /clear @a without an item, which wipe everyone’s inventory instantly and cannot be undone without restoring a backup.

Clear vs dropping items

Pressing Q drops items onto the ground where they can be picked up again for five minutes, while /clear deletes them immediately. If you are not sure whether you will need something later, drop it into a chest instead of clearing it.

Tip: type /clear @s and a space to see item ID suggestions, which avoids spelling mistakes.

Test with maxCount 0 first if you are unsure what a command will remove.

Clearing the offhand and armor only

In Java, the /item command can replace a single slot, such as the offhand or the helmet slot, with air, which removes just that item without touching the rest of the inventory. This is more precise than /clear when you only want to take off a player’s armor for a minigame. In Bedrock, /replaceitem does a similar job.

Cleared items are gone for good.

Plan before you clear.

More about Minecraft

See all