Skip to content
WikilyWIKILY
All games23 Wikis · pick your game
Commands and cheatsAll commands

Switch game

23 Wikis · pick your game
/clear

Command

/clear

Removes items from players' inventories, or counts how many matching items they carry.

Syntax

/clear [<targets> [<item> [<maxCount>]]]

Arguments

ArgumentKind of valueWhat to type
<targets>Target selectorThe players whose inventories are cleared. Defaults to yourself. One or more players.
<item>Item testWhich items to remove: an item id such as minecraft:diamond, an item tag such as #minecraft:logs, or * for any item, optionally followed by component tests in square brackets. Defaults to every item.
<maxCount>Whole numberThe largest number of items to remove from each player. A whole number of 0 or more. 0 only counts. Without it, all matching items are removed. At least 0.

Details

Permission level2: operators, worlds with cheats on, command blocks and functions
Works inSingleplayer with cheats enabled and multiplayer servers. Needs permission level 2 (gamemasters): server operators, players with cheats, command blocks, and functions can all run it.
ResultReports how many items were removed and from whom, or how many matching items were found when only counting. The number /execute store saves is that number of items, added up over all targeted players.
No argumentsRemoves everything from your own inventory. This form only works when a player runs it.
Only targetsRemoves every item from the targeted players.
What is searchedThe whole inventory including armor and off hand, the 2x2 crafting grid, and the item held on the mouse cursor.
Counting onlyA maxCount of 0 removes nothing and just reports how many matching items the players have. This is a way to test whether a player carries an item.
FailureFails with "No items were found" if no targeted player had a matching item.

Examples

/clear

Empties your own inventory.

/clear @a minecraft:diamond

Removes all Diamonds from every player.

/clear @s minecraft:dirt 32

Removes up to 32 Dirt from you.

/clear @p #minecraft:logs

Removes every kind of log from the nearest player.

/clear @s minecraft:diamond 0

Counts your Diamonds without removing any.

Join the creator communityThe people who build the Minecraft Java Edition wiki are on our Discord. Ask questions or suggest pages.Join Discord (opens Discord in a new tab)