Command basics
Three things to know before your first command: how commands are built, how coordinates work, and who target selectors point at.
1 - Anatomy
How a command is built
/give @s diamond 64/givethe command
@sthe target (who)
diamondthe item
64how many
Read it left to right: command → target → details. Parts in <…> are required, […] are optional.
2 - Coordinates
Finding your way: X, Y, Z
east (+) / west (−)
up (+) / down (−) - height
south (+) / north (−)
100 64 -200Absolute
Exact spot in the world.
~ ~ ~Relative (~)
Your current position.
~ ~5 ~Relative + offset
Same spot, 5 blocks up.
^ ^ ^3Local (^)
Relative to where you're facing - 3 blocks ahead.
3 - Target selectors
Who does it affect?
Selectors start with @ and choose who a command targets. Pick one below and watch who lights up.
Go deeper
Beyond the basics
Command blocksRun commands from inside the world, automatically.+
Grab one in Creative (you need operator permissions):
/give @s command_blockPlace it, then right-click to open it and type a command (no leading / needed inside the block). Three types:
- Impulse - runs once each time it gets a redstone pulse.
- Repeat - runs every tick while powered or “Always Active”.
- Chain - runs right after the block pointing into it runs.
Toggle Needs Redstone / Always Active and Conditional in the block's UI.
NBT & data tagsExtra data attached to entities, blocks, and items.+
NBT is the extra data you can add in {curly braces}. On entities it still works directly:
/summon zombie ~ ~ ~ {CustomName:'"Bob"',IsBaby:true}For items, newer Java (1.20.5+) switched from NBT tags to components in [square brackets]:
/give @s diamond_sword[enchantments={sharpness:5}]Older Java versions used {Enchantments:[...]}, and Bedrock handles this differently - always match your version.
/execute deep diveThe command that powers almost every advanced trick.+
Chain subcommands to set context, then run a command inside it:
/execute as @a at @s run tp ~ ~5 ~- as <targets> - change who @s refers to.
- at <targets> - change where the command runs from.
- positioned / rotated / facing - fine-tune the spot and direction.
- if / unless - only run when a condition is true (entity, block, score).
- store - save the result into a score or NBT.
The example above bounces every player 5 blocks up - one command, run once per player, from each player's position.
Build your first commandPut it all together, step by step.+
- Open chat with T (or /) - or place a command block.
- Type / and start the command name (try the autocomplete in our simulator).
- Add a target selector, like @s.
- Fill in the rest - coordinates, items, amounts.
- Press Enter and watch it happen.
Stuck on a specific one? Every command page here has examples, common mistakes, and a live preview.