/

/clear

op 2Items

/clear removes items from player inventories. With no arguments it empties your own inventory; narrowing it to one item, and optionally a maximum count, makes it precise enough for minigames and shops.

Commandready
15
/clear @p stone
Press C to copy
optional
Nearest player
@p

Who or what the command applies to

optional
Item components1.20.5+none

A plain item needs nothing here. Add a component to give it a name, lore, enchantments or custom data.

optional

Leave empty to clear everything that matches. 0 only counts, without removing.

Examples

  • Wipe an inventory
    /clear @s
  • Take 5 dirt
    /clear @p dirt 5
  • Count without removingReturns how many they hold
    /clear @p diamond 0

Common questions about /clear

How do I check whether a player has an item without taking it?

Set the maximum count to 0. /clear @p diamond 0 removes nothing and returns the number held, which /execute store result can capture into a score.

Does /clear match custom items?

It matches on the components or NBT you specify. An item with no component filter matches every stack of that item, custom name or not.