In minecraft 1.19.2, I used this command to give myself the iron boots:

/give @p iron_boots{Unbreakable:1,Tags:[Special],display:{Name:'[{"text":"Heavy Boots","italic":false,"color":"green"}]'},Enchantments:[{id:vanishing_curse,lvl:1},{id:protection,lvl:2}],HideFlags:4} 1

I then used this command to check if one is wearing the boots and grant the effect but it doesnt add the effect.

execute as @a if entity @s[nbt={Inventory:[{Slot:100b,id:"minecraft:iron_boots",tag:{Tags:["Special"],display:{Name:"{\"text\":\"Heavy Boots\"}"}}}]}] run effect give @s minecraft:slowness 1 0 true

The problem is this command doesnt the effect. Although after removing the tag of the item check, that is this command.

execute as @a if entity @s[nbt={Inventory:[{Slot:100b,id:"minecraft:iron_boots"}]}] run effect give @s slowness 1 0 true

It works without a problem, on every pair of iron boots that is, so I found out that I'm probably doing something wrong with formatting.

Please can you explain what I did wrong and not only provide a solution? It would really help me in avoiding this mistake in the future. Thanks!

  • Possible duplicate of Why is it bad practice to test for item names?
    – pppery
    Sep 1, 2022 at 2:31
  • 2
    @pppery This situation is slightly different: they already have a custom item tag in their existing commands. The answer there simply says "use a custom item tag," and if we redirect them to that question, they will just say "but I already HAVE a custom item tag, whaddya mean?" Therefore, the answer on the duplicate target is not sufficient, and I had to post a different answer here for the specific situation. The fact that the question's specific situation warranted a different answer than on the duplicate should be sufficient to keep these two questions as related, and not duplicates.
    – One 2 Many
    Sep 1, 2022 at 5:32
  • It's becoming clear that the community does not agree with my broad definition of "duplicate", but IMO these are still two questions suffering from the exact same problem (of command NBT failing to detect item names because of formatting tweaks), so should have been closed.
    – pppery
    Sep 1, 2022 at 13:28

1 Answer 1


In your /give, you wrote this:

Name: '[{"text":"Heavy Boots","italic":false,"color":"green"}]'

But in your /execute, you wrote this:

Name: "{\"text\":\"Heavy Boots\"}"

When you compare item names, the NBT processor is doing a plain text comparison on the raw JSON source of the item name, not the rendered output of that JSON source.

In fact, the NBT processor does not even know that display: {Name: '…'} contains JSON text, and frankly, it does not even care.

What it does care about is that '[{"text":"Heavy Boots","italic":false,"color":"green"}]' and "{\"text\":\"Heavy Boots\"}" are undoubtedly different strings, even though the produced text is the same. But since the JSON text is different, the item names do not match.

But wait! Before you change the item names to match, consider this:

You are already using a custom item tag in your /give command:

give @p iron_boots{Tags:[Special]}

This is the right way to do it! Instead of testing for the custom item name, test for a custom item tag instead!

In fact, you are already doing this in your current command:

execute as @a if entity @s[nbt={Inventory:[{Slot:100b,id:"minecraft:iron_boots",tag:{Tags:["Special"],display:{Name:"{\"text\":\"Heavy Boots\"}"}}}]}]

But, in addition to having the custom tag check, you also have a custom name check there too. This defeats the purpose of a custom tag, since the custom tag is supposed to help you suppress the custom name check, but you still had one anyways.

So, to sum up what you need to do, the best way to fix your problem using good practices is only to test for the custom item tag, and not test for the custom item name.

Main article and further examples: Why is it bad practice to test for item names?

  • Thank you so much for an explanation! Right now I don't really have time to check it out, but as soon as I try it out I'll mark it as an answer. Sep 1, 2022 at 5:53

You must log in to answer this question.

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