/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.

Operator (cheats on)Cheats must be onChecked on 1.26.66.1

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

Parameters

ParameterWhat it means
player: targetThe 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: ItemThe 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: intAn 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: intThe 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.

/clear

Removes every item from the inventory of the player who runs the command.

/clear @p

Clears the entire inventory of the nearest player.

/clear @a red_wool

Removes all red wool blocks from every player online.

/clear @s minecraft:granite 0 16

Removes up to 16 granite blocks from the player running the command.

/clear @p diamond_sword -1 1

Removes one diamond sword from the nearest player, regardless of how much durability damage the sword has taken.

/clear @p emerald -1 0

Checks if the nearest player has any emeralds and outputs the total count without removing any of them.

/clear @a[m=adventure] TNT

Removes all TNT from every player who is currently in Adventure mode.

/clear @a[r=20] wet_sponge -1

Removes all wet sponges of any data value from all players within 20 blocks.

/clear @r[tag=prisoner] warped_door 0 1

Removes 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 @s

Clears 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

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.