I am making a custom Minecraft map in which I need to /testfor if a player has a totally empty inventory. I tried Googling but I didn't get any results. So if anyone can help me by providing suitable /testfor command it would be very very helpful.

  • Have you made any attempt to solve this yourself? Arqade works better when askers show effort to solve their own problems; we see that you have a problem you've worked on, and answerers respond to that. You also get a more specific answer that's tailored exactly to the part you're stuck, and Arqade gets a very specific question. Everybody wins!
    – Frank
    Apr 15, 2016 at 12:19
  • Thx for ur opinion. Im a noob to this stack exchange world so i dont know some stuffs
    – Tom
    Apr 15, 2016 at 13:34
  • And it's in your best interest to show that you won't waste ours or other's time. You are free to ask questions all you like, but we do expect you to display some effort. You'll get a better response when you do.
    – Frank
    Apr 15, 2016 at 15:07
  • I can't comment more without knowing why you want to test for this, but make sure your design can't be exploited by throwing everything down, getting whatever you're giving them for having nothing, and then picking their stuff back up.
    – Random832
    Apr 15, 2016 at 15:41

2 Answers 2


Use this command:

/testfor @a {Inventory:[]}

I tried this and it seems to work, but if you encounter any problems, please comment and I will look into it.

  • 3
    This will indeed work; testing for an empty list tag will check if the target's list is also empty. As the inverse, checking for the existence of a compound will return if the player had any items at all (/testfor @a {Inventory:[{}]}).
    – Skylinerw
    Apr 15, 2016 at 12:28
  • ash4funs i tried your code but it isn't working it say players does not meet the data tag
    – Tom
    Apr 15, 2016 at 13:30
  • @KartikPillai Are you certain that your inventory is empty? You have no armor or anything else?
    – Angelica
    Apr 15, 2016 at 14:19
  • Im 100% sure that there is no items including armor in my inventory
    – Tom
    Apr 15, 2016 at 14:20
  • try swapping the @a for @p
    – Angelica
    Apr 15, 2016 at 14:23

1.13+ update

/testfor was superseded by /execute if entity. Therefore, the new command is as follows:

/execute if entity @p[nbt={Inventory:[]}] run ...

If you want to include ender chest inventory, you can use:

/execute if entity @p[nbt={Inventory:[],EnderItems:[]}] run ...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .