🧠
Advanced
/execute
The Swiss-army command — run other commands as anyone, anywhere, if a condition is met.
At a glance
Syntax
Syntax
/execute as <target> at <anchor> run <command>commandtargetcoordsvaluerequiredoptional
See it
What it does
as @a run jump
One command runs for every target
Anatomy
Every part, explained
- 1
CommandRequired/executeSets up context for another command to run inside.
- 2
AsOptionalas <target>Whose 'self' (@s) the inner command runs as.
- 3
AtOptionalat <anchor>Where the inner command runs from.
- 4
RunRequiredrun <command>The actual command to execute. Always comes last.
Your turn
Try it yourself
Playground
10 tokens · press Enter to run
Copy & paste
Examples
/execute as @a at @s run tp ~ ~5 ~Bounce every player 5 blocks up.
/execute as @e[type=cow] run effect give @s glowingMake all cows glow.
/execute if entity @e[type=creeper] run say Boom incoming!Only say it if a creeper exists.
Avoid these
Common mistakes
✕
/execute as @a run @s tp ~ ~5 ~✓
/execute as @a at @s run tp ~ ~5 ~After 'run' you write a plain command — no extra target.
✕
/execute run say hi as @a✓
/execute as @a run say hi'run' must be last — everything after it is the command.
Keep going