Skip to main content
← All Guides
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.

server console, survival
>/execute as @a at @s run particle flame ~ ~1 ~
as @arun once per online player
at @sexecute at that player's position
runthe command to perform
[Server] Executed 4 times for 4 entities
<Notch> nice particles
[12:04:09] [Server thread/INFO]: tick ok
Read it like a sentence
  1. 1
    Start with /execute
    Type /execute on its own. It does nothing yet, it is a wrapper that changes the context for the command you attach at the end.
  2. 2
    Add an “as” clause
    as @a sets the executor to every online player, one run each. Use @e[type=zombie] or @p to target other entities instead.
  3. 3
    Add an “at” clause
    at @s moves the execution position to wherever the current executor stands, so relative ~ ~ ~ coords resolve from them.
  4. 4
    Filter with conditionals
    Chain if/unless to gate the command, e.g. if block ~ ~-1 ~ minecraft:water before the run clause.
  5. 5
    End with run
    run 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.
Hosting
Skip the setup
Get a managed server with one click instead of configuring it all yourself.
Database
Target selector reference
Look up every entity type, block id, and selector argument you can drop into an /execute chain.