Barrier

Minecraft Clear Command Generator

A bare /clear wipes the whole inventory. The scoped forms are the useful ones: name an item id to remove only that item, cap the count to charge a fee instead of taking everything, and set the max to 0 to count matching items without removing any.

  • Target selector, item id and max count
  • max 0 dry-run counts without clearing
  • Whole-inventory form only when you actually mean it

FAQ

How do I count matching items without removing them?

Set the max count to 0. /clear <target> <item> 0 reports how many the player has and removes nothing, which is the standard way to test an inventory before acting on it.

How do I remove only a specific item?

Name the item id and, optionally, a max count. /clear @p minecraft:dirt 64 removes up to 64 dirt and leaves everything else; a bare /clear wipes the whole inventory.

Can /clear match items by their custom data?

On modern versions you can add a component or NBT filter so only items matching that data are cleared -- useful for removing a specific named quest item without touching similar plain items.