Minecraft /execute command
Runs a command as someone else, at another position or only if a condition is met.
Syntax
/execute as <targets> run <command>
/execute at <targets> run <command>
/execute if block <pos> <block> run <command>
/execute if entity <entities> run <command>
/execute positioned <pos> run <command>
/execute in <dimension> run <command>
/execute store result score <targets> <objective> run <command>
Parts in square brackets are optional, parts in angle brackets are required. You do not type the brackets: Put your own value in their place.
Arguments
| Argument | What it does |
|---|---|
| as | Changes who runs the command (@s now refers to them). |
| at | Changes the position and rotation the command runs at. |
| if / unless | A condition: Checks a block, entity, score or data. |
| store | Writes the command's result to a score or a data field. |
Examples
/execute as @a at @s run playsound minecraft:entity.player.levelup master @s
Plays a sound at each player's own position.
/execute at @e[type=creeper] run particle minecraft:flame ~ ~1 ~
Shows flames above every creeper.
/execute if block ~ ~-1 ~ diamond_block run say you are standing on diamond
Runs based on the block under your feet.
/execute as @a[scores={points=10..}] run tag @s add winner
Tags everyone with 10 or more points.
Good to know
- as and at are different: as changes who it is, at changes where it is. They are usually written together.
- Subcommands can be chained; run always comes last.
- It replaced the old execute syntax in 1.13.
How do I run this command?
Press T in game to open chat (or press / directly), type the command and press Enter. While typing, Tab completes the options. This command counts as a cheat: It needs cheats enabled in a singleplayer world, and operator permission on a server (operator (level 2)).
Related commands
⚙️ More Advanced commands
Minecraft is a product of Mojang Studios. This tool is an independent helper made for players and is not affiliated with Mojang or Microsoft.