All commands
๐Ÿง 
AdvancedJava โœ“Bedrock โœ“

/execute

The Swiss-army command - run other commands as anyone, anywhere, if a condition is met.

๐ŸชจBedrock note: Bedrock's /execute exists but supports fewer subcommands than Java.

Overview

What is the /execute command?

The /execute command is the most powerful command in Minecraft. It doesn't do one thing โ€” it changes the context of another command: who runs it, where, facing which way, and only if certain conditions are met. Subcommands like as, at, positioned, facing, if, unless and store chain together to express complex logic in a single line.

Nearly every advanced datapack, redstone-free machine and map mechanic is built on /execute. Mastering it is the gateway from casual commands to real command engineering.

When to use it: Use /execute to run a command as or at another entity, conditionally, or with a changed position/rotation โ€” the heart of advanced command logic.

At a glance

Syntax

Syntax
/execute as <target> at <anchor> run <command>
commandtargetcoordsvaluerequiredoptional

See it

What it does

as @a run jump
One command runs for every target

Anatomy

Every part, explained

  1. 1
    /executeCommandRequired

    Sets up context for another command to run inside.

  2. 2
    as <target>AsOptional

    Whose 'self' (@s) the inner command runs as.

  3. 3
    at <anchor>AtOptional

    Where the inner command runs from.

  4. 4
    run <command>RunRequired

    The actual command to execute. Always comes last.

Your turn

Try it yourself

Playground
10 tokens ยท press Enter to run

Copy & paste

Examples

/execute as @a at @s run tp ~ ~5 ~

Bounce every player 5 blocks up.

/execute as @e[type=cow] run effect give @s glowing

Make all cows glow.

/execute if entity @e[type=creeper] run say Boom incoming!

Only say it if a creeper exists.

Avoid these

Common mistakes

โœ•/execute as @a run @s tp ~ ~5 ~
โœ“/execute as @a at @s run tp ~ ~5 ~

After 'run' you write a plain command - no extra target.

โœ•/execute run say hi as @a
โœ“/execute as @a run say hi

'run' must be last - everything after it is the command.

Good to know

Frequently asked questions

What does /execute do in Minecraft?
It runs another command in a modified context โ€” as a different entity, at a different position, facing a direction, or only if a condition is true.
How do you run a command for every player?
Use /execute as @a run <command>; it executes the command once per matching player.
What's the difference between 'as' and 'at'?
'as' changes who runs the command (the executor); 'at' changes where it runs from (the position). They're often combined: execute as @a at @s ...

Keep going

Related commands