The /clear Command: How to Clear Your Inventory Completely or Remove a Specific Item
What the /clear command is and why you need it. In standard mode, the inventory holds 36 item slots and 4 armor slots. The /clear command…
What the /clear command is and why you need it
In standard mode, the inventory holds 36 item slots and 4 armor slots. The /clear command removes items from these slots.
A full clear removes all items from the inventory. Removing a specific item takes away only the specified type (for example, all diamonds or all apples). Removing with a specified amount takes away a certain number of items.
How to use the /clear command
Open the chat with the T or / key, type the command, and press Enter. The command takes effect immediately after execution.
Basic syntax:
/clear [selector] [item] [amount] [NBT tags]
[selector]— the player whose items are removed (default is@s— the player themselves)[item]— the type of item to remove (optional; if not specified, all items are removed)[amount]— the number of items to remove (optional; if not specified, all items of that type are removed)[NBT tags]— additional item parameters (optional, for advanced use)
How to clear your inventory completely
A command without a specified item removes all items from the inventory, including armor and items in hand.
Examples:
Clear your own inventory:
/clear
Clear the nearest player's inventory:
/clear @p
Clear the inventory of all players on the server:
/clear @a
Clear a specific player's inventory by name:
/clear PlayerName
After the command is executed, all items are removed permanently. They can only be restored through item-granting commands or by loading a backup of the world.
How to remove a specific item
Specifying an item type in the command removes only items of that type; the rest stay in the inventory.
Examples:
Remove all diamonds:
/clear @s minecraft:diamond
Remove all apples:
/clear @s minecraft:apple
Remove all iron swords:
/clear @s minecraft:iron_sword
Remove all dirt blocks:
/clear @s minecraft:dirt
Remove all items of a specific type from the nearest player:
/clear @p minecraft:diamond
The command removes all items of the specified type, regardless of how many are in the inventory. If there are no items of that type, the command runs without an error but removes nothing.
How to remove a specific number of items
The amount parameter limits the number of items removed. Items are removed in the specified quantity; the rest stay in the inventory.
Examples:
Remove 10 diamonds:
/clear @s minecraft:diamond 10
Remove 5 apples:
/clear @s minecraft:apple 5
Remove 1 diamond sword:
/clear @s minecraft:diamond_sword 1
Remove 64 stone blocks:
/clear @s minecraft:stone 64
If the inventory has fewer items of the specified type than stated in the command, all available items of that type are removed. The command does not produce an error if there are fewer items than the requested amount.
How to clear other players' inventories
Instead of @s, you can specify another player using selectors or a name.
Player selectors:
@s— the player executing the command@p— the nearest player@a— all players on the server@r— a random playerPlayerName— a specific player by name
Examples:
Clear the entire inventory of the nearest player:
/clear @p
Remove all diamonds from all players:
/clear @a minecraft:diamond
Remove 10 diamonds from a random player:
/clear @r minecraft:diamond 10
Clear a specific player's inventory:
/clear Steve
On a server, the command only works for players with operator permissions. Regular players cannot clear other participants' inventories.
Advanced use: NBT tags and item data
NBT tags let you remove items with specific properties: enchantments, durability, names, and other parameters.
Examples:
Remove all enchanted diamond swords:
/clear @s minecraft:diamond_sword 0 {Enchantments:[{}]}
Remove all diamond swords with a specific enchantment:
/clear @s minecraft:diamond_sword 0 {Enchantments:[{id:"minecraft:sharpness"}]}
Remove items with a specific name:
/clear @s minecraft:diamond_sword 0 {display:{Name:'{"text":"Special Sword"}'}}
NBT tags require an exact match of all specified parameters. If an item does not meet all the conditions, it is not removed. For a detailed study of NBT tags, a separate article is recommended.
Limitations and usage notes
Permission requirements:
The /clear command only works for players with operator permissions or in creative mode. In survival mode without operator permissions, the command is not available.
Minecraft versions:
The command is available in all versions of Minecraft. The syntax may differ in older versions (before 1.13). In versions 1.13+, the new item-name format with the minecraft: prefix is used.
Removing items:
Items are removed permanently. They can only be restored through granting commands (for example, the the /give command for granting items) or by loading a backup of the world. Items do not drop when removed.
Multiplayer:
On a server, every player with operator permissions can clear their own inventory. An administrator can clear other players' inventories by specifying their name or selector instead of @s.
Effect on achievements:
Using the /clear command does not block earning achievements. The game considers this a legitimate way to manage your inventory.
Working with command blocks:
The /clear command can be used in command blocks for automation. For example, clearing all players' inventories when they enter an arena, or removing specific items on a timer.
Common errors and how to fix them
Error: "You do not have permission to use this command"
Cause: lack of operator permissions.
Solution: enable cheats in the world settings (for single-player) or obtain operator permissions on the server. In single-player, cheats are enabled in the world settings before creating it, or by opening the world to the local network with cheats enabled.
Error: "No entity was found"
Cause: an incorrect target selector or player name.
The player name is case-sensitive and must match exactly.
Error: "Unknown item"
Cause: an incorrect item name or a typo.
Solution: check the spelling. The name must begin with minecraft: and contain the correct item name. For example, minecraft:diamond, not diamond or minecraft:Diamond.
No comments yet. Be the first to share your thoughts.