Commands
How to Use the /execute Command
/execute is the most powerful command in Minecraft because it reshapes the context for any other command. Learn to read the clause chain, as @a at @s run …, and you can run anything from anyone, anywhere.
Read it like a sentence
- 1Start with /executeType /execute on its own. It does nothing yet, it is a wrapper that changes the context for the command you attach at the end.
- 2Add an “as” clauseas @a sets the executor to every online player, one run each. Use @e[type=zombie] or @p to target other entities instead.
- 3Add an “at” clauseat @s moves the execution position to wherever the current executor stands, so relative ~ ~ ~ coords resolve from them.
- 4Filter with conditionalsChain if/unless to gate the command, e.g. if block ~ ~-1 ~ minecraft:water before the run clause.
- 5End with runrun is always last. Everything after it is the actual command: run tp @s ~ ~5 ~ or run particle flame ~ ~1 ~.
What you need
Command block or chat
as / at clauses
@s & @a selectors
run subcommand
Quick answers
?
What does /execute actually do?
It runs another command in a modified context, a different executor (as), position (at), rotation (rotated), or dimension (in). The command after run is what runs.
?
What is the difference between as and at?
as changes WHO runs the command (@s and selectors update). at changes WHERE it runs from (relative coords and ^ local coords resolve there). You usually want both: as @a at @s.
?
What does @s mean inside /execute?
@s refers to the current executor of that clause. After as @a, @s is each individual player in turn, which is why as @a at @s is the standard player loop.
?
Can I chain more than one condition?
Yes. Stack as many if and unless clauses as you like before run, e.g. /execute as @a if entity @s[scores={kills=1..}] run say got a kill.
?
What replaced the old /execute syntax?
Since Java 1.13 the command uses subcommands (as, at, run) instead of the legacy /execute <target> <pos> <command> form. Old syntax no longer works.
?
How do I store a result in a scoreboard?
Use store: /execute store result score @s health run data get entity @s Health writes the command's output into a fakeplayer or score.
/execute at a glance
Syntax
/execute <subcommand> ... run <command>Who may run it
OP (L2)
What it does
Modifies the execution context of a command. Supports changing the executor, position, dimension, rotation,…
Three things /execute is actually used for
/execute as @a run give @s minecraft:bread 3Runs the give once per player, so everyone ends up with three bread rather than one player getting it all.
/execute at @a run setblock ~ ~-1 ~ minecraft:glassPuts a glass block under every player, each at their own position, because at moves the position to the target.
/execute if block ~ ~-1 ~ minecraft:water run say standing on waterOnly runs the second command when the condition holds, which is how conditional logic works without a datapack.
Every command with its full argument list lives in the command reference.
Blocks and items in this guide
All 2 of these are named in the guide above, starting with Potion. Look them up in the item database.
More guides on this site
Guides that go with this one
How to Make a Fire Resistance Potion in Minecraft
Full recipe for the Potion of Fire Resistance in Minecraft 1.21+ Java Edition. Learn the brewing chain,...
How to Run Server Giveaways That Actually Bring Players
Learn how to plan and execute Minecraft server giveaways that attract real players and boost retention....
How to Use the /clone Command in Minecraft
Copy any region to a new spot with /clone. Learn the source and destination syntax, the replace, masked,...
How to Use the /fill Command in Minecraft
Fill any region with one block using /fill x y z x2 y2 z2 block. Learn solid, hollow, outline and...
How to Use the /gamemode Command in Minecraft
<> One command swaps a player between Survival, Creative, Adventure and Spectator. Learn the full...
How to Use the /setblock Command in Minecraft
Place any block at exact coordinates with /setblock. Learn relative ~ and absolute syntax, block states,...
Database →
Command Reference
Syntax, arguments and examples for every command.
Hosting →
Managed Hosting
Skip the setup: a managed server online in minutes.
Database →
Item Database
Every item with its stats, IDs, recipes and uses.
Guides →
More Server & Admin guides
Run a server: setup, hosting, permissions, worlds and crossplay.