How the /execute Command Works
The /execute command lets you modify the context before running another command. You can change who runs it (as), where it runs (at, positioned), which dimension (in), or add conditions (if, unless). The final run subcommand specifies what to execute.
Common /execute Patterns
Run as every player at their position
/execute as @a at @s run say Hello from my position!
Conditional: only if a block exists
/execute if block ~ ~-1 ~ minecraft:diamond_block run give @s minecraft:diamond 1
Run in the Nether
/execute in minecraft:the_nether positioned 0 64 0 run setblock ~ ~ ~ minecraft:glowstone
Negated condition
/execute unless entity @a[distance=..5] run say No players nearby
Subcommand Reference
as <targets> — Run the command as the specified entities.
at <targets> — Run the command at the specified entities' position, rotation, and dimension.
positioned <x> <y> <z> — Run the command at the given coordinates.
in <dimension> — Run the command in the specified dimension.
if block <pos> <block> — Continue only if the block at pos matches.
if entity <targets> — Continue only if the targets exist.
unless block <pos> <block> — Continue only if the block does NOT match.
unless entity <targets> — Continue only if the targets do NOT exist.
run <command> — The final command to execute. Must be last.
Need item or block IDs for your conditions? Browse the Minecraft Item ID List or Minecraft Block IDs page.
Execute Command Builder FAQ
What does the /execute command do in Minecraft?
The /execute command modifies the context of another command — changing who runs it, where it runs, or adding conditions. For example, /execute as @a at @s run say hello makes every player say hello from their own position.
Can I chain multiple execute subcommands?
Yes. You can chain as many subcommands as you need before the final run. For example: /execute as @p at @s if block ~ ~-1 ~ minecraft:diamond_block run give @s minecraft:diamond 1 checks for a diamond block below the nearest player before giving them a diamond.
What is the difference between as and at?
as changes the executor (who runs the command), at changes the execution position (where the command runs). Using both together is common: as @p at @s means run as the nearest player at their location.
Do I need OP to use /execute?
Yes. /execute requires operator permissions or cheats enabled, same as /give and /setblock.