/clear
The /clear command removes items from a player's inventory, including their armor slots and offhand. You can wipe an entire inventory at once, or filter by item ID, data value, and maximum count. Setting the maximum count to 0 lets you check if a player has an item without actually taking it away.
Syntax
Exactly as the game prints it. <angle brackets> are required, [square brackets] are optional.
/clear [player: target] [itemName: Item] [data: int] [maxCount: int]What it is used for
- Resetting player inventories when they enter a minigame lobby or start a new round.
- Removing banned or overpowered items like TNT or Ender Pearls from players in a specific zone.
- Taking a specific amount of currency items from a player to process a custom shop purchase.
- Detecting if a player is carrying a key item by clearing 0 of that item in a repeating command block.
Parameters
| Parameter | What it means |
|---|---|
player: target | The player or players whose inventory will be cleared. Accepts a player name or a target selector like @p, @a, @r, or @s. If omitted, it defaults to the player running the command. |
itemName: Item | The identifier of the item to remove, such as red_wool or minecraft:diamond. You can include or omit the minecraft: namespace. If omitted, all items in the player's inventory are cleared. |
data: int | An integer that filters by the item's data value or durability damage. Use -1 to match any data value or durability level. If omitted, it defaults to -1. |
maxCount: int | The maximum number of matching items to remove from the player. Use 0 to test how many matching items the player has without removing any. If omitted, all matching items are removed. |
Examples
Every example below was sent to a real Bedrock Dedicated Server (1.26.66.1) and accepted by the game.
/clearRemoves every item from the inventory of the player who runs the command.
/clear @pClears the entire inventory of the nearest player.
/clear @a red_woolRemoves all red wool blocks from every player online.
/clear @s minecraft:granite 0 16Removes up to 16 granite blocks from the player running the command.
/clear @p diamond_sword -1 1Removes one diamond sword from the nearest player, regardless of how much durability damage the sword has taken.
/clear @p emerald -1 0Checks if the nearest player has any emeralds and outputs the total count without removing any of them.
/clear @a[m=adventure] TNTRemoves all TNT from every player who is currently in Adventure mode.
/clear @a[r=20] wet_sponge -1Removes all wet sponges of any data value from all players within 20 blocks.
/clear @r[tag=prisoner] warped_door 0 1Removes a single warped door from one random player who has the prisoner tag.
/execute as @a at @s if block ~ ~-1 ~ bamboo_block run clear @sClears the entire inventory of any player who steps directly on top of a bamboo block.
Common mistakes
Running /clear in a command block with no target selector and getting an error.
Always specify a target like @p or @a when using a command block, because the block itself does not have an inventory to clear by default.
Damaged weapons, tools, or armor are not being cleared when you set data to 0.
For items with durability, the data parameter represents damage taken. Set data to -1 so the command matches the item regardless of how worn it is.
Syntax error when trying to specify maxCount right after itemName.
You cannot skip parameters in the middle of a command. You must provide a data value (use -1 for any) before you can type the maxCount number.
A custom shop takes a player's items even when they have fewer than the required price.
Setting maxCount to 10 will still remove 5 items if the player only has 5. Use the hasitem target selector argument first to verify the player has the full amount before running /clear.
Tips
- Use /clear @p <item> -1 0 in a repeating command block connected to a comparator or a conditional chain command block to trigger events whenever a player holds a specific item.
- When building custom shops, pair /clear with the hasitem selector argument, such as /clear @p[hasitem={item=emerald,quantity=10..}] emerald -1 10, so you only take items from players who can afford the full price.
- Keep in mind that /clear also removes items currently held in the player's cursor slot if they have their inventory screen open.
Questions about /clear
Does /clear remove equipped armor and items in the offhand slot?
Yes. The command checks the main inventory, hotbar, offhand slot, and all four armor slots. If a matching item is worn or held in the offhand, it will be removed.
Does /clear remove items stored inside a player's Ender Chest?
No, it only affects the player's direct inventory slots. To empty a player's Ender Chest, you must use the /replaceitem command on the slot.enderchest slots.
Can I use /clear to remove items from a chest or a mob?
No, the target parameter only accepts players. To remove items from containers like chests or from mobs, use /replaceitem with air as the item.
More from 9Minecraft
Command reference © 2026 9Minecraft.net. Syntax read from Minecraft Bedrock Edition 1.26.66.1.