Skip to main content

/clear

Removes items from a player's inventory. Can target specific items and limit how many are removed.

Category
Player
Permission Level
Game Master
Version Added
1.0

Syntax

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

Parameters

NameTypeRequiredDescription
targetsentityOptionalThe player(s) whose inventory to clear. Defaults to the executing player.
itemitem_predicateOptionalThe item to remove. If omitted, all items are cleared.
maxCountintegerOptionalThe maximum number of items to remove. If 0, counts matching items without removing them.

Examples

/clear @p

Clears the entire inventory of the nearest player.

/clear @a minecraft:dirt

Removes all dirt blocks from every player's inventory.

/clear @s minecraft:diamond 0

Checks how many diamonds the executing player has without removing any (useful in command blocks).

Common Mistakes

Notes

When maxCount is 0 the command succeeds if the player has the item but removes nothing. This is useful for testing in conditional command blocks.

Related Commands

/give/item/replaceitem

Need a Minecraft server?

Try these commands on Astroworld or host your own server.

Try Astroworld Hosting