Minecraft /execute Command
Executes a command using modified context: changing the executor entity (as), position (at / positioned), rotation, dimension, or evaluating complex conditions (if / unless).
Version Compatibility
Command Syntax
/execute <subcommands...> run <command>/execute <subcommands...> run <command>Arguments Explained
as <entity>SubcommandChanges who the executor (@s) is, without moving where the command runs.
at <entity>SubcommandChanges execution position (~ ~ ~), rotation, and dimension to match the entity.
positioned <pos>SubcommandExplicitly moves the execution location to coordinates (absolute or relative).
in <dimension>SubcommandExecutes within minecraft:overworld, the_nether, or the_end.
if / unless <condition>SubcommandEvaluates block matches, entity counts, score comparisons, or predicates before running.
store (result|success)SubcommandStores the numeric result or success count of the command into a scoreboard or NBT path.
run <command>TerminatorRequiredThe terminating command executed if all modifiers and condition checks succeed.
Practical Examples
/execute as @a at @s if block ~ ~-1 ~ minecraft:water run effect give @s speed 5 1 trueGives speed boost to players who are currently standing on top of water.
Detecting ground blocks beneath players.
/execute as @e[type=cow] at @s run summon lightning_boltStrikes a lightning bolt at every cow in loaded chunks.
Changing both identity and position context.
/execute in minecraft:the_nether run tp @s 0 64 0Teleports the player to coordinates 0, 64, 0 in the Nether dimension.
Cross-dimensional teleportation.
/execute store result score @p CoinCount run clear @p gold_nugget 0Counts how many gold nuggets a player holds and stores the number in their CoinCount scoreboard.
Querying inventory amounts into variables without removing items.
/execute at @e[type=arrow] if block ~ ~-0.5 ~ minecraft:sand run setblock ~ ~-0.5 ~ minecraft:glassTurns sand into glass wherever an arrow lands.
Dynamic projectile impact mechanics.
Common Mistakes
Mistake:
Confusing "as" and "at": using "as @a" expecting relative coordinates ~ ~ ~ to match the player
Fix:
"as" only changes who @s is. To shift coordinates, you must also specify "at @s": /execute as @a at @s run ...
Mistake:
Forgetting the mandatory "run" keyword before the final command
Fix:
Every modern /execute chain must terminate with "run <command>".
Mistake:
Creating infinite command loops in Repeating Command Blocks that crash the server
Fix:
Add a tag filter (e.g. @e[tag=!processed]) and tag the entity inside the command loop to prevent repeat execution.
Java vs Bedrock Differences
Both Java and modern Bedrock support "as", "at", "positioned", "if block", "if entity", and "if score". Java Edition additionally supports "if data", "if predicate", "if loaded", and dimension switching via "in".
Command Block Usage & Automation
The cornerstone of command block logic. Run a Repeating Always Active command block with "/execute as @a at @s if block ~ ~-1 ~ slime_block run effect give @s jump_boost 2 3 true" to create custom trampoline jump pads, or use conditional chain blocks following execute checks to only advance storylines when a puzzle condition is met.
Useful Tips
Use "align xyz" after "positioned" to snap floating decimal coordinates to the nearest block corner.
Combine "if entity @a[distance=..5]" to build reliable proximity triggers without bulky redstone sensors.
Store command success (/execute store success score ...) to build binary true/false switches in scoreboards.
Important Notes
In Bedrock Edition 1.19.50+, the modern Java-like execute syntax was standardized. Older Bedrock syntax (/execute <origin> <pos> <command>) is deprecated and should not be used in modern worlds.
Frequently Asked Questions
Why does my relative coordinate ~ ~ ~ still run at the command block instead of the player?
You used "as @a" without "at @s". "as" only changes identity; "at" changes location. Use both: /execute as @a at @s run ...
Does Bedrock Edition support modern execute syntax?
Yes! Since Bedrock 1.19.50, Bedrock fully supports modern chained execute subcommands matching Java.
Can execute run multiple commands at once?
No, /execute can only terminate with one "run" command. Use function files (.mcfunction) to trigger multiple commands.
Related Commands
Ready to build your command?
Use our interactive generator to create error-free /execute commands with a visual interface.
Open Command Generator