Updated:

Basic form

/loot give @p loot minecraft:chests/simple_dungeon

Rolls the dungeon chest loot and gives the result to the nearest player. Each run gives different items.

A /loot command has two parts: where the items go, and what to roll.

Where the items go

SyntaxDestination
give @pThe player's inventory
spawn ~ ~1 ~Dropped as items at that position
insert 10 64 10Into the chest or container there
replace block 10 64 10 container.0Replaces a container slot
replace entity @p hotbar.0Replaces a player slot

What to roll

SyntaxResult
loot <table>Chest, fishing and other loot tables
kill <entity>What that mob would drop (it is not killed)
mine <pos> [tool]What that block would drop (it is not broken)
fish <table> <pos>One catch from fishing at that spot

Examples

/loot spawn ~ ~1 ~ loot minecraft:chests/end_city_treasure
/loot give @p kill @e[type=minecraft:zombie,limit=1,sort=nearest]
/loot give @p mine ~ ~-1 ~ minecraft:diamond_pickaxe
/loot give @p fish minecraft:gameplay/fishing ~ ~ ~

Common loot tables

IDContents
minecraft:chests/simple_dungeonDungeon chest
minecraft:chests/desert_pyramidDesert temple
minecraft:chests/buried_treasureBuried treasure
minecraft:chests/bastion_treasureBastion treasure room
minecraft:chests/end_city_treasureEnd city
minecraft:chests/ancient_cityAncient city
minecraft:gameplay/fishingFishing

Press Tab while typing to list every ID. To roll the loot when a chest is first opened, place a chest with a LootTable instead.

Build a gacha machine

/loot give @p[scores={coins=10..}] loot minecraft:chests/simple_dungeon
/scoreboard players remove @p[scores={coins=10..}] coins 10

Only players with 10 or more coins get a prize, and they pay 10 coins. Run both lines in order from a button and you have a prize machine. For the coin score, see the scoreboard guide. For your own prize list, make a custom loot table in a data pack.

Bedrock Edition

Bedrock also has /loot, but loot tables are written differently and fewer destinations exist. Follow the suggestions as you type.

Common problems

Common questions

Check your command

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