Minecraft Java · 1.16+
/clear
Clear an inventory or match items by ID, tag and conditions.
Count without removal
Choose Count only. The editor adds 0 to the command, which counts matching items.
Clear the entire inventory
Choose All items and leave maximum blank. Check the target before running the command.
Item predicates
From Java 1.20.5, use component tests such as minecraft:diamond_pickaxe[damage=0].
FAQ Frequently asked questions 30 questions
Essential questions 5
What is /clear used for?
It removes matching items from a player's inventory. It can also count items without deleting them.
Can /clear accidentally empty an inventory?
Yes. Running /clear without an item filter removes all matching inventory items from the target player. Review the arguments carefully.
Can I remove only one item type?
Yes. Specify the registered item ID. For example, minecraft:dirt limits removal to dirt instead of clearing the whole inventory.
Can /clear check quest requirements?
Yes. With an amount of zero, it detects matching items and returns their count without removing them.
Does /clear remove world blocks?
No. It operates on player inventory items, not placed blocks. World modifications require different commands.
Syntax and arguments 5
What is the /clear syntax?
Java Edition uses /clear [targets] [item] [maxCount]. Optional arguments are useful, but omitting them can clear the entire inventory.
What does targets mean?
It specifies whose inventory should be searched or cleared. Use a player name or an appropriate player selector.
What does maxCount mean?
It limits the number of matching items removed. At zero, items are counted without deletion.
What happens when item is omitted?
The command is not restricted to one item type. A normal removal operation may therefore clear the player's whole inventory.
Can I use the @a selector?
Yes. @a targets all matching players. Be especially careful when combining it with item removal on a public server.
Practical examples 5
How do I count stone without removing it?
Run /clear @s minecraft:stone 0. It detects matching stone items without deleting them from the inventory.
How do I remove up to ten dirt items?
Use /clear @s minecraft:dirt 10. If fewer than ten matching items exist, only the available amount is removed.
How do I remove a player's cobblestone?
For example, /clear Steve minecraft:cobblestone removes matching cobblestone from Steve. Verify the target player first.
How do I check whether I have diamonds?
Run /clear @s minecraft:diamond 0 to count matching diamonds. It does not consume the player's items.
How do I empty my entire inventory?
Use /clear @s only when you intend to remove all matching items. Move valuable items somewhere safe before running it.
Advanced usage 5
Can I filter by item components?
Modern Java versions use item predicates, allowing supported item properties to be checked with the appropriate syntax.
Can /clear implement an item payment system?
It can check and remove items, but a reliable transaction needs result verification and protection against repeated execution.
Can /clear run through /execute?
Yes. /execute can establish the execution context. Verify the executor and selected player target before running the command.
Can I remove only a specified quantity?
Yes. maxCount limits removal. If fewer matching items exist, the command does not create or compensate for missing items.
Can I retrieve the number of removed items?
Yes. The command result reports matching items removed or detected and can be used with suitable /execute store logic.
Troubleshooting 4
Why did /clear remove nothing?
The inventory may not contain matching items, or the filter may be wrong. Check the selected player and target availability.
Why did /clear remove too many items?
You may have omitted the item filter or maxCount. Inspect the complete command before trying again.
Why does /clear fail from the server console?
Without an explicit target, the console has no player inventory of its own. Specify a player name or a suitable selector.
Why does the item filter fail?
The identifier may be unknown, or the component predicate syntax may not match your version. Start with a plain item ID.
Minecraft versions 3
How do Java and Bedrock /clear commands differ?
Their arguments differ, including Bedrock's data-related parameter. Do not copy one edition's syntax directly into the other.
Why do old item filters fail?
Item and component formats have changed across Java Edition versions. Verify that the current version supports your predicate syntax.
Should I account for changes after Java 1.20.5?
Yes. Item components changed many item-related command arguments. Older NBT examples may require conversion.
Permissions and safety 3
What permission level does /clear require?
Java Edition normally requires permission level 2. Removing other players' items should be restricted to authorized users.
How do I test a clear command safely?
First use the same item filter with maxCount zero. It checks matches without actually deleting inventory items.
Can I undo an inventory clear?
The /clear command does not provide an automatic undo. Recovery requires previously prepared mechanisms or saved data.
Rate this tool
Did this tool work for you? Tell us what went well or what could improve.
Sign in to leave a review