How to Use the Clear Command – Wiki Guide
This Minecraft tutorial explains how to use a game command to clear your inventory with screenshots and step-by-step instructions.
You can clear items from a player’s inventory using the /clear command in Minecraft. Let’s explore how to use this cheat (game command).
Requirements
To run game commands in Minecraft, you have to turn cheats on in your world.
Clear Command
Clear Command in Minecraft Java Edition (PC/Mac)
In Minecraft Java Edition (PC/Mac) 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19 and 1.20, the syntax to clear items from a player’s inventory is:
/clear [targets] [item] [maxCount]
In Minecraft Java Edition (PC/Mac) 1.8, 1.9, 1.10, 1.11 and 1.12, the syntax to clear items from a player’s inventory is:
/clear [targets] [item] [data] [maxCount] [dataTag]
Definitions
- targets is optional. It is the name of the player (or a target selector) whose inventory you wish to clear. If no player is specified, it will default to the player running the command.
- item is optional. It is the item to clear (See list of Minecraft items). If no item is specified, then all items in the player’s inventory will be cleared.
- data is optional. It is the data value of the item to clear. It identifies the variation of the block if more than one type exists for that Item ID (See list of data values). Use a value of 0 if no data value exists for the item. If you omit this parameter or use -1 for the data value, the match will be performed on the item only and ignore the data value.
- maxCount is optional. It is the maximum number of items that will be cleared. If you omit this parameter or use -1, all matching items will be cleared.
- dataTag is optional. It is the data tag that you want to set for the item being cleared. It is a compound NBT tag such as {Potion:harming} or {EntityTag:{id:Creeper}}.
Examples
Example in Java Edition (PC/Mac) 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19 and 1.20
To remove all items from your inventory in Minecraft 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19 and 1.20:
/clear
To clear 9Minecraft’s inventory:
/clear 9Minecraft
To clear diamond swords from all players’ inventory:
/clear @a diamond_sword
To clear 2 diamond swords from all players’ inventory:
/clear @a diamond_sword 2
To remove all diamond swords that are enchanted with Sharpness (any level of this enchantment) from 9Minecraft’s inventory:
/clear 9Minecraft diamond_sword{ench:[{id:16}]}
To remove all diamond swords that are enchanted with Sharpness V (only level 5 of this enchantment) from 9Minecraft’s inventory:
/clear 9Minecraft diamond_sword{ench:[{id:16,lvl:5}]}
Examples that Check for Items in a Player’s Inventory
Finally, you can use the /clear command to check if an item is in a player’s inventory. This is done by setting maxCount to 0 in the /clear command.
To check the number of TNT that 9Minecraft has in inventory:
/clear 9Minecraft tnt 0
To check the number of enchanted diamond swords (Sharpness V) each player has in their inventory:
/clear @a diamond_sword{ench:[{id:16,lvl:5}]} 0
Example in Java Edition (PC/Mac) 1.11 and 1.12
To remove all items from your inventory in Minecraft 1.11 and 1.12:
/clear
To clear TNT from all players’ inventory:
/clear @a tnt
To clear 10 TNT from all players’ inventory:
/clear @a tnt 0 10
To clear red carpet from all players’ inventory:
/clear @a carpet 14
To remove all fishing rods that are enchanted with Luck of the Sea (any level of this enchantment) from 9Minecraft’s inventory:
/clear 9Minecraft fishing_rod 0 -1 {ench:[{id:61}]}
To remove all fishing rods that are enchanted with Luck of the Sea III (only level 3 of this enchantment) from 9Minecraft’s inventory:
/clear 9Minecraft fishing_rod 0 -1 {ench:[{id:61,lvl:3}]}
Examples that Check for Items in a Player’s Inventory
Finally, you can use the /clear command to check if an item is in a player’s inventory. This is done by setting maxCount to 0 in the /clear command.
To check the number of TNT that 9Minecraft has in inventory:
/clear 9Minecraft tnt 0 0
To check the number of enchanted fishing rods (Luck of the Sea III) each player has in their inventory:
/clear @a fishing_rod 0 0 {ench:[{id:61,lvl:3}]}
How to Enter the Command
1. Open the Chat Window
The easiest way to run a command in Minecraft is within the chat window. The game control to open the chat window depends on the version of Minecraft:
- For Java Edition (PC/Mac), press the T key to open the chat window.
- For Pocket Edition (PE), tap on the chat button at the top of the screen.
- For Xbox One, press the D-Pad (right) on the controller.
- For PS4, press the D-Pad (right) on the controller.
- For Nintendo Switch, press the right arrow button on the controller.
- For Windows 10 Edition, press the T key to open the chat window.
- For Education Edition, press the T key to open the chat window.
2. Type the Command
In this example, we will remove all items from your inventory with the following command:
/clear
Type the command in the chat window. As you are typing, you will see the command appear in the lower left corner of the game window. Press the Enter key to run the command.
Once the cheat has been entered, your inventory will be cleared:
You will see the message “Cleared the inventory of <Name>, removing xxx items” appear in the lower left corner of the game window to indicate that the inventory was cleared.
Congratulations, you just learned how to use the /clear command in Minecraft!