Skip to content
WikilyWIKILY
All games23 Wikis · pick your game
Commands and cheatsAll commands

Switch game

23 Wikis · pick your game
Item Components

Command reference

Item Components

Items in commands are written as an id followed by components in square brackets. Components hold everything special about an item, such as its name, enchantments and durability.

Details

Item syntaxid[component=value,component=value]. The minecraft: part of ids and component names may be left out.
Removing a componentPut ! before the name with no value, for example minecraft:diamond_sword[!attribute_modifiers].
RepeatingEach component may appear only once per item.
ValuesWritten in the data format: numbers, quoted text, lists in [ ] and named values in { }.
Component types119 that can be used in commands.
Item testsUsed by /clear and /execute if items. Start with an item id, an item tag with #, or * for any item, then optional tests in [ ].
Combining testsA comma means both tests must pass, | means either may pass, ! before a test reverses it.
Exact testcomponent=value passes when the item has exactly that value.
Partial testname~value checks part of a component. Available for attribute_modifiers, bundle_contents, container, custom_data, damage, enchantments, firework_explosion, fireworks, jukebox_playable, potion_contents, stored_enchantments, trim, villager/variant, writable_book_content and written_book_content.
Count testcount=5 for an exact stack size, or count~{min:..,max:..} for a range.
Where data in braces still appliesEntity and block data: /summon, /data, the nbt selector argument and block data after a block id.

Common components

enchantmentsEnchantments on the item with their levels/give @s minecraft:diamond_sword[enchantments={sharpness:5,unbreaking:3}]
stored_enchantmentsEnchantments held by an enchanted book/give @s minecraft:enchanted_book[stored_enchantments={mending:1}]
custom_nameName shown for the item, as a text component/give @s minecraft:stick[custom_name={text:"Magic Wand",color:"gold",italic:false}]
item_nameBase name of the item, as a text component/give @s minecraft:stick[item_name="Wand"]
loreExtra tooltip lines, a list of text components/give @s minecraft:stick[lore=["First line",{text:"Second line",color:"gray"}]]
damageDurability already used up/give @s minecraft:diamond_pickaxe[damage=100]
max_damageTotal durability/give @s minecraft:diamond_pickaxe[max_damage=5000]
unbreakableItem never loses durability/give @s minecraft:diamond_pickaxe[unbreakable={}]
max_stack_sizeLargest stack, 1 to 99/give @s minecraft:ender_pearl[max_stack_size=64]
attribute_modifiersAttribute changes while the item is in a slot/give @s minecraft:stick[attribute_modifiers=[{type:"minecraft:attack_damage",amount:10,id:"example:bonus",operation:"add_value",slot:"mainhand"}]]
potion_contentsPotion type, color and custom effects/give @s minecraft:potion[potion_contents={custom_color:16711680,custom_effects:[{id:"minecraft:speed",amplifier:1,duration:600}]}]
dyed_colorDye color as one number or as [red,green,blue] from 0 to 1/give @s minecraft:leather_chestplate[dyed_color=16711680]
fireworksFlight time and explosions of a rocket/give @s minecraft:firework_rocket[fireworks={flight_duration:2,explosions:[{shape:"large_ball",colors:[I;16711680],fade_colors:[I;255],has_trail:true,has_twinkle:true}]}]
firework_explosionExplosion of a firework star/give @s minecraft:firework_star[firework_explosion={shape:"star",colors:[I;65280]}]
written_book_contentTitle, author and pages of a written book/give @s minecraft:written_book[written_book_content={title:"Guide",author:"Steve",pages:["Page one",{text:"Page two",bold:true}]}]
writable_book_contentPages of a book and quill/give @s minecraft:writable_book[writable_book_content={pages:["Notes"]}]
foodHunger and saturation restored when eaten/give @s minecraft:stick[food={nutrition:4,saturation:2.4,can_always_eat:true},consumable={}]
consumableMakes the item usable by eating or drinking/give @s minecraft:stick[consumable={consume_seconds:0.8,animation:"eat"}]
tooltip_displayHides the tooltip or single components in it/give @s minecraft:diamond_sword[enchantments={sharpness:5},tooltip_display={hidden_components:["minecraft:enchantments"]}]
enchantment_glint_overrideForces the enchantment shine on or off/give @s minecraft:stick[enchantment_glint_override=true]
rarityName color class: common, uncommon, rare or epic/give @s minecraft:stick[rarity="epic"]
custom_dataFree data for data packs/give @s minecraft:stick[custom_data={quest_item:1b}]
custom_model_dataValues that resource packs use to pick a model/give @s minecraft:stick[custom_model_data={floats:[1.0f],strings:["wand"]}]
item_modelModel used to draw the item/give @s minecraft:stick[item_model="minecraft:blaze_rod"]
can_breakBlocks the item can break in Adventure mode/give @s minecraft:diamond_pickaxe[can_break={blocks:"#minecraft:logs"}]
can_place_onBlocks the item can be placed on in Adventure mode/give @s minecraft:stone[can_place_on={blocks:"minecraft:grass_block"}]
containerItems stored inside a container item/give @s minecraft:chest[container=[{slot:0,item:{id:"minecraft:diamond",count:3}}]]
bundle_contentsItems inside a bundle/give @s minecraft:bundle[bundle_contents=[{id:"minecraft:arrow",count:16}]]
profilePlayer whose skin a player head shows/give @s minecraft:player_head[profile={name:"Notch"}]
trimArmor trim material and pattern/give @s minecraft:iron_chestplate[trim={material:"minecraft:gold",pattern:"minecraft:coast"}]
equippableLets the item be worn in a slot/give @s minecraft:stick[equippable={slot:"head"}]
use_cooldownWait time in seconds after use/give @s minecraft:ender_pearl[use_cooldown={seconds:5}]
repair_costExtra anvil cost in levels/give @s minecraft:diamond_sword[repair_cost=10]
block_entity_dataBlock data applied when the block is placed/give @s minecraft:spawner[block_entity_data={id:"minecraft:mob_spawner",Delay:20s}]
entity_dataEntity data applied when the item creates an entity/give @s minecraft:armor_stand[entity_data={id:"minecraft:armor_stand",Small:1b}]

Item tests

idThat item/clear @s minecraft:diamond
#tagAny item in the tag/clear @s #minecraft:planks
*Any item/clear @s *
[component]Items that have the component/clear @s *[damage]
[!component]Items that do not have the component/clear @s *[!damage]
[component=value]Items whose component is exactly the value/clear @s minecraft:diamond_sword[damage=0]
[name~value]Items that pass a partial test/clear @s *[enchantments~[{enchantments:"minecraft:sharpness",levels:{min:3}}]]
[count=n]Stacks of exactly that size/clear @s minecraft:stick[count=5]
[count~{min:n}]Stacks in a size range/clear @s *[count~{min:32}]
[a|b]Items that pass either test/clear @s *[damage|unbreakable]
[a,b]Items that pass both tests/clear @s #minecraft:swords[enchantments~[{}],!custom_name]

Data value types

ByteWhole number with b1b
ShortWhole number with s20s
IntegerWhole number, or with i5
LongWhole number with L4L
FloatNumber with f5.5f
DoubleNumber with a decimal point, or with d6.5d
True or falsetrue or false, stored as 1b or 0btrue
TextIn double or single quotes. Simple words need no quotes"Steve"
ListValues in [ ] separated by commas[1,2,3]
Named valueskey:value pairs in { }{id:"minecraft:diamond",count:3}
Byte list[B; ...][B;1b,2b]
Integer list[I; ...][I;1,2]
Long list[L; ...][L;1L,2L]
Hex or binary number0x or 0b in front0x1F
Unsigned or signedu or s before the type letter255ub
Digit groupingUnderscores between digits1_000
bool(...)Turns a number into true or falsebool(1)
uuid(...)Turns a UUID text into its stored formuuid("dd12be42-52a9-4a91-a8a1-11c01849e498")

Where data in braces is used

Entity data on summon/summon minecraft:pig ~ ~ ~ {NoAI:1b}
Changing entity data/data merge entity @n[type=minecraft:zombie] {NoAI:1b,CustomName:"Bob"}
Reading with a data path/data get entity @s Inventory[{id:"minecraft:diamond"}].count
Component inside a data path/data get entity @s SelectedItem.components."minecraft:damage"
Block data/data get block ~ ~ ~ Items[0]
Command storage/data modify storage my_pack:data name set value "Steve"
Selector filter/kill @e[type=minecraft:zombie,nbt={NoAI:1b}]

Examples

/give @s minecraft:diamond_sword[custom_name={text:"Excalibur",color:"gold",italic:false},enchantments={sharpness:5},unbreakable={}]

Gives an unbreakable Sharpness V sword with a gold name.

/give @s minecraft:diamond_sword[!attribute_modifiers]

Gives a diamond sword without its attack damage and speed bonuses.

/give @s minecraft:potion[potion_contents={potion:"minecraft:strong_healing"}]

Gives a Potion of Healing II.

/item replace entity @s weapon.mainhand with minecraft:diamond_sword[enchantments={sharpness:5}]

Puts a Sharpness V diamond sword in your main hand.

/clear @s *[damage~{durability:{max:10}}]

Removes every item with 10 or less durability left.

/execute if items entity @s weapon.mainhand minecraft:diamond_sword run say yes

Says yes if you hold a diamond sword.

/execute if items entity @s container.* *[custom_data~{key:1b}] run say yes

Says yes if any inventory slot holds an item whose custom data has key set to 1b.

/data merge storage my_pack:data {a:1,b:2b,c:3s,d:4L,e:5.5f,f:6.5d,g:"text",h:[1,2,3],i:[B;1b,2b],j:[I;1,2],k:[L;1L,2L],l:{m:true}}

Stores one value of each data type.

Join the creator communityThe people who build the Minecraft Java Edition wiki are on our Discord. Ask questions or suggest pages.Join Discord (opens Discord in a new tab)