Minecraft · Guide

Minecraft Target Selectors Explained: @p, @a, @r, @s, @e, @n

Every Minecraft target selector and filter for Java and Bedrock, side by side, with examples.

Game Respawned Editorial TeamUpdated November 5, 2026

Target selectors let a command pick who it affects: @p is the nearest player, @a is every player, @r is a random player, @s is whoever runs the command, @e is every entity, and @n (Java only) is the nearest entity. Add filters in square brackets, such as @e[type=zombie,distance=..10].

Intermediate Java Bedrock

The selectors

SelectorPicks
@sThe entity running the command (you in chat, the target in an execute command)
@pThe nearest player
@aAll players
@rA random player
@eAll entities: players, mobs, dropped items, armor stands and more
@nThe nearest entity (Java only)

Filters for Java and Bedrock

Filters go in square brackets and are separated by commas. Put an exclamation mark before a value to say not, as in type=!player.

What to filterJavaBedrock
Entity typetype=zombietype=zombie
Distancedistance=..10r=10 (max) and rm=2 (min)
How manylimit=1c=1 (negative picks the farthest)
Sort ordersort=nearest, furthest, randomUse c together with the selector
Namename=Stevename=Steve
Tagtag=bosstag=boss
Game modegamemode=survivalm=survival
Experience levellevel=5..l=5 (max) and lm=1 (min)
Scorescores={kills=5..}scores={kills=5..}
Box areax= y= z= dx= dy= dz=x= y= z= dx= dy= dz=
NBT datanbt={...}Not available

A range uses two dots. In Java, 5.. means 5 or more, ..5 means 5 or less and 1..5 means 1 to 5. Bedrock scores use the same range style.

Examples

Kill the nearest zombie to you

Java:    /kill @e[type=zombie,limit=1,sort=nearest]
Bedrock: /kill @e[type=zombie,c=1]

Give an effect to every player within 20 blocks

Java:    /effect give @a[distance=..20] regeneration 10
Bedrock: /effect @a[r=20] regeneration 10

Teleport everyone except yourself to you

Java:    /tp @a[distance=1..] @s
Bedrock: /tp @a[rm=1] @s

Remove all dropped items

/kill @e[type=item]

Common mistakes

  • Using @e with no type. It matches every entity, so /kill @e kills items, mobs and armor stands, and in some cases players. Always add a type.
  • Using @s in a command block. A command block is not a player. Use @p, a tag, or execute as.
  • Mixing editions. distance and limit are Java. r and c are Bedrock.
  • Forgetting a comma between filters. They need commas but no spaces.

FAQ

What does @e mean in Minecraft?

@e selects every entity: players, mobs, dropped items, armor stands and more. Add type=zombie or another filter to narrow it.

What is the difference between @p and @s?

@p is the nearest player to where the command runs. @s is the entity that is running the command.

How do I select only mobs and not players?

Use @e[type=!player]. Be careful, because that still includes items and armor stands.

What is @n in Minecraft?

@n selects the nearest entity of any kind. It exists in Java Edition only.

Why does my selector filter not work on Bedrock?

Bedrock uses different parameters from Java: r and rm for distance, c for the number of targets, m for game mode and l and lm for levels.

Checked by the Game Respawned editorial team against the current Java and Bedrock versions. Spotted something out of date? Tell us.