Updated:

What changed

Up to 1.20.4, extra item data went in one {...} NBT block. From 1.20.5, name, enchantments, durability and so on are separate components written in [...] right after the item ID.

Up to 1.20.4 (NBT)1.20.5+ (components)
Where{ } after the ID[ ] right after the ID
Separator:=
EnchantmentsEnchantments:[{id:"sharpness",lvl:5}]enchantments={sharpness:5} (1.21.5+)
UnbreakableUnbreakable:1bunbreakable={}
Namedisplay:{Name:'...'}custom_name=...

The same /give in both formats

# Up to 1.20.4
/give @p diamond_sword{Enchantments:[{id:"sharpness",lvl:5}],Unbreakable:1b} 1
# 1.21.5+
/give @p diamond_sword[enchantments={sharpness:5},unbreakable={}] 1

Between 1.20.5 and 1.21.4 there are more differences, such as enchantments={levels:{sharpness:5}}. Rather than track them by hand, choose your version in the give command generator.

Why components are better

Entities and blocks still use NBT

Only items moved to components. Mob data in /summon (such as {NoAI:1b}) and block data such as chest contents are still NBT. Items held by a mob inside that NBT use the component form.

/summon zombie ~ ~ ~ {NoAI:1b}

See how an item is stored

/data get entity @s SelectedItem

On Java this shows the ID and components of the item in your hand, a useful model for writing /give.

Bedrock Edition

This change only affects Java. Bedrock /give takes an amount, a data value and a small JSON block for a few fields such as can_destroy.

Common questions

Check your command

The Command Error Doctor checks common syntax mistakes in your browser.