Clear Command Generator — /clear Inventory Items (Java Edition)
Most of these need operator permission — run them from an op's chat, a command block, or the server console.
How to Use the Clear Command Generator
- Leave the target as
@sto clear your own inventory, or enter another player name / selector like@ato clear everyone’s. - Leave the item box empty to remove everything, or enter an item ID like
minecraft:cobblestoneto remove only matching items. - Optionally set a max count – with an item specified, this caps how many of that item get removed instead of clearing all matching stacks.
- Copy the generated
/clearcommand into a command block, the console, or an operator’s chat.
Command Syntax Reference
/clear [target] [item] [maxCount]
With no arguments, /clear wipes the executor’s entire inventory including armor and offhand. Adding an item ID restricts removal to that item only, leaving everything else untouched. The max count only matters when an item is specified – without a max count, all matching stacks are removed; with one, removal stops once that many items have been cleared and any beyond that stay in the inventory. /clear also reports how many items were removed, which is useful for validating a player has (or doesn’t have) something via a following /execute if check.
Frequently Asked Questions
Does /clear remove armor and the offhand slot too?
Yes – a plain /clear with no item filter empties every inventory slot: hotbar, main inventory, armor slots, and the offhand. If you only want to clear held/hotbar items, specify an item ID to filter what gets removed.
Can I use /clear just to check if a player has an item, without removing it?
Not directly with /clear itself, but the trick is to set max count to 0 – this makes the command test and report the matching count without actually removing anything, which is commonly combined with /execute if for item-check logic in command blocks.
What happens if I specify an item the player doesn’t have?
Nothing is removed and the command reports zero items cleared – /clear never errors out or affects other items when the specified item isn’t present in the target’s inventory.
Does clearing remove items with custom NBT or enchantments?
Yes, as long as the base item ID matches – a plain /clear @s minecraft:diamond_sword removes an enchanted diamond sword just the same as a plain one, since the command matches on item type by default rather than requiring exact NBT.
Related Tools
- Recipe Command Generator – lock or unlock recipes instead of removing items already in inventory.
- XP Command Generator – adjust experience separately from clearing items.
- Gamemode Command Generator – switch to creative to freely restock after clearing.