The /execute command
Run another command as someone else, somewhere else, or only if a condition is true. The most powerful command there is.
What it does
/execute doesn't do much on its own — it changes the context that another command runs in. You chain subcommands (who runs it, where, and under what conditions), then finish with run <command>. It's the backbone of almost every advanced pack.
Syntax
execute <subcommand> ... run <command> - as <target>
- Run as each matched entity (changes who @s is).
- at <target>
- Run at the target’s position and rotation.
- positioned <x y z>
- Run at a specific position.
- if / unless
- Only run when a condition holds — if block, if entity, and more.
- run <command>
- The command to run in the built-up context.
Examples
execute as @a at @s run setblock ~ ~-1 ~ glass Put a glass block under every player’s feet.
execute at @p run summon lightning_bolt ~ ~ ~ Strike lightning at the nearest player’s position.
execute if block ~ ~-1 ~ water run say You are over water Only say the message when there’s water below.
See it in action
Before and after running /execute — in MiniBench's 3D preview and in Minecraft.
Command run
execute as @s at @s run fill ~-1 ~ ~8 ~1 ~2 ~10 emerald_block
Before
After
Not affiliated with Mojang or Microsoft. Minecraft is a trademark of Mojang Synergies AB.
Watch out for
- · Bedrock uses the modern execute syntax (1.19.50+), which matches Java’s subcommand style — older guides may show the outdated form.
- · Order matters: as changes who @s is, but not the position — add at @s to also move the context there.
- · Chain as many subcommands as you like before run.
Write it in MiniBench with autocomplete and live validation, then run it in Minecraft.