Execute Command Generator
Build execute commands using as, at, if entity, if block, and run.
How to use
Build the command step by step: select the executor with as, the position with at and then the condition.
Basic fallback generator
A simplified form is available while the main generator loads. It does not include every setting in the full tool.
Output
Related guide
Read examples of command execution context, selectors and common syntax errors.
Command generator guideExecute command: as, at and run
The most common confusion is the difference between who runs a command and where the command runs.
Examples and checks
| Subcommand | Meaning |
|---|---|
as | Changes the executing entity. |
at | Changes the execution position. |
/execute as @a at @s run particle minecraft:happy_villager ~ ~1 ~How /execute is built
An execute command is a chain of steps that ends with run. as changes who runs the command, at changes where it runs, and if or unless add conditions.
For example, /execute as @a at @s if block ~ ~-1 ~ minecraft:gold_block run say I am on gold checks the block under every player and runs only for those standing on gold.
If the command does not work
- Without
at @s, the position stays at the command block, so~does not mean the player's position. - Bedrock Edition uses the same new syntax from version 1.19.50. Older Bedrock worlds use the old form.
- If nothing happens, test the condition first with
saybefore running the real command.
Copy-ready execute examples (Java, Bedrock 1.19.50+)
| Goal | Command |
|---|---|
| Strike lightning on every player | /execute at @a run summon minecraft:lightning_bolt ~ ~ ~ |
| Speed boost when standing on gold | /execute as @a at @s if block ~ ~-1 ~ minecraft:gold_block run effect give @s minecraft:speed 5 1 |
| Warn when a zombie is close | /execute as @a at @s if entity @e[type=minecraft:zombie,distance=..10] run say A zombie is near me |
| Teleport players inside an area | /execute positioned 0 64 0 run tp @a[distance=..5] 100 64 100 |
| Save your Y level to a score (Java) | /execute as @a store result score @s y run data get entity @s Pos[1] |
as changes who runs the command (so @s means that entity) and at moves the position to them (so ~ ~ ~ is their feet). Most player-based commands need both. if and unless stop the command when the condition fails. On Bedrock, write effect @s speed 5 1 without give, and the store example is Java only.
Old syntax
Java 1.12 and earlier, and Bedrock before 1.19.50, used /execute @a ~ ~ ~ command. That form no longer works on current versions; rewrite it with as and at.