/clear @pThe /clear command removes items from player inventories. Without an item filter, it removes everything. Set max count to 0 to detect if a player has an item without removing it.
The /clear command removes items from player inventories. You can wipe everything, target a specific item type, or set a max count to remove only a certain number. This generator builds the correct syntax for any clearing scenario.
The syntax is /clear [targets] [item] [maxCount]. All parameters are optional: running /clear alone wipes your entire inventory, an item removes only that type, and maxCount limits how many are removed per execution.
The command removes items from all inventory slots: main inventory, hotbar, offhand and armor. It does not affect ender chests, world containers, or items on the ground.
| Command | Effect |
|---|---|
| /clear @s | Wipes your entire inventory - all slots including armor and offhand |
| /clear @s diamond | Removes all diamonds from your inventory |
| /clear @s diamond 5 | Removes up to 5 diamonds (keeps any beyond 5) |
| /clear @s diamond 0 | Tests if you have diamonds without removing any (detection mode) |
| /clear @a cobblestone | Removes all cobblestone from every player online |
Detection trick: setting maxCount to 0 runs the command without removing anything. It succeeds if the player has the item and fails if they do not, which is how command blocks and /execute if detect items.
The /clear command removes items from a player's inventory. Without arguments it clears everything. You can specify an item type to only remove that item, and a max count to limit how many are removed. It works on every item in Java Edition.
Use /clear <target> <item>. For example, /clear @s diamond removes all diamonds from your inventory. Add a max count to limit removal: /clear @s diamond 5 removes up to 5 diamonds.
Yes. Set the max count to 0: /clear @s diamond 0. This tests whether the player has any diamonds without removing them. The command's success or failure can be read by conditional command blocks or /execute if.
Yes. The /clear command removes items from all inventory slots, including the main inventory, hotbar, offhand, and all four armor slots. It does not distinguish between equipped and unequipped items.
Browse more Minecraft tools: