Target selectors are the shorthand that lets a Minecraft command pick who or what it acts on without typing player names. Instead of /tp Steve 100 64 100, you can write /tp @p 100 64 100 and the game resolves the nearest player automatically. This reference covers all six Java Edition selector variables (@p, @r, @a, @e, @s, @n) and every filter argument you can add in square brackets, current for Minecraft Java 26.2.
To run any of these, open the chat window by pressing T (or /, which pre-types the slash) and enter a command. On a multiplayer server you can also type commands into the server console without the leading slash. Cheat commands generally require operator/permission level 2, so make sure cheats are enabled or you are opped. Want to build selectors visually and copy the exact string? Use our free Minecraft Target Selector tool.
The Six Selector Variables at a Glance
| Selector | Targets | Default sort / limit | Example |
|---|---|---|---|
@p | Nearest player. If tied, the most recently joined player wins. | sort=nearest, limit=1 | tp @p 100 64 100 |
@r | A random online player (Java can target a random entity with type=). | sort=random, limit=1 | give @r diamond 1 |
@a | All online players, including dead/respawning players. | sort=arbitrary, no limit | gamemode adventure @a |
@e | All alive entities in loaded chunks (players, mobs, items, etc.). | sort=arbitrary, no limit | kill @e[type=zombie] |
@s | The entity that executed the command. Selects nothing if the executor is not an entity. | self only | tag @s add marked |
@n | Nearest alive entity of any type, not just players. | sort=nearest, limit=1 | data get entity @n |
Players vs Entities: @a @p @r vs @e @n @s
@a, @p and @r always resolve to players. In Java you cannot use type= to make them target a mob — that argument only re-types @e, @n and @s. A key gotcha: @a includes dead players who are still respawning, whereas @e only matches alive entities in loaded chunks. So gamemode adventure @a catches everyone, but @e[type=player] may miss a player mid-respawn.
@e is the broadest selector and almost always needs narrowing. kill @e[type=zombie] removes every zombie, and @e[type=!player] targets every non-player entity. @n is the entity-aware cousin of @p — @n[type=cow] is the nearest cow. @s refers only to the command’s executor and is the backbone of /execute chains: it selects nothing from a command block or the bare server console because neither is an entity, but it can select a dead entity.
Selector Arguments (Filters)
Arguments go inside square brackets and are combined with logical AND: @e[type=zombie,distance=..10] means zombies and within 10 blocks. Java is case-sensitive. Many arguments can be negated with ! and repeated for multiple exclusions.
| Argument | Syntax | What it filters | Example |
|---|---|---|---|
| type | type= / type=! / type=# | Entity type; # for entity-type tag, ! to exclude (one positive value only). | @e[type=creeper] |
| distance | distance= | Euclidean distance in blocks. Java ranged floats; cannot be negative. | @e[distance=5..15] |
| limit | limit= | Max targets returned, applied after sort. | @e[type=item,limit=5] |
| sort | sort=nearest|furthest|random|arbitrary | Order targets are chosen before limit. | @a[limit=3,sort=furthest] |
| x, y, z | x= | Override the search origin (Java: not center-corrected). | @e[x=100,y=64,z=200,distance=..10] |
| dx, dy, dz | dx= | Cuboid volume by hitbox intersection from the origin. | @e[x=0,y=64,z=0,dx=5,dy=3,dz=5] |
| tag | tag= / tag=! / tag= | Custom /tag tags; empty matches no tags, ! matches any tag. | @e[tag=marked,tag=!done] |
| scores | scores={ | Scoreboard objective values (integer or range), ANDed. | @a[scores={kills=10..}] |
| nbt (Java only) | nbt= / nbt=! | Entity NBT match via stringified NBT. | @e[type=sheep,nbt={Color:0b}] |
| gamemode | gamemode=survival|creative|adventure|spectator | Player game mode, negatable. | @a[gamemode=!spectator] |
| name | name= / name=! | Exact name (case-sensitive; quote spaces). | @e[name="My Dog"] |
| level | level= | Player experience level. | @a[level=30..] |
| x_rotation | x_rotation= | Head pitch: -90 up, 0 horizon, +90 down. | @e[x_rotation=..0] |
| y_rotation | y_rotation= | Yaw: -180 north, -90 east, 0 south, +90 west. | @e[y_rotation=-45..45] |
| team (Java only) | team= / team=! / team= | Scoreboard team; empty = no team. | @a[team=red] |
| advancements (Java only) | advancements={ | Advancement or criterion completion. | @a[advancements={story/smelt_iron=true}] |
| predicate (Java only) | predicate= / predicate=! | Data-pack predicate match. | @e[predicate=mypack:is_underwater] |
Sort and Limit: Order Matters
Sort always runs before limit. That is why default limits pair with default sorts: @p and @n use sort=nearest, limit=1; @r uses sort=random, limit=1; @a and @e use sort=arbitrary with no limit (arbitrary is the fastest ordering). Override them together — @e[type=item,limit=5,sort=nearest] returns the five closest dropped items, while @a[limit=3,sort=furthest] returns the three players farthest from the execution point. You cannot raise @s beyond one target.
Position, Distance and Volume
By default a selector searches from the command’s execution position. Override the origin with x, y, z — in Java these are not center-corrected, so x=0 means exactly 0.0. Combine with distance for a sphere (@e[distance=..10] = within 10 blocks) or with dx/dy/dz for a box. The cuboid spans from (x,y,z) to (x+dx, y+dy, z+dz) plus one block, and selection is by hitbox intersection, not entity center. Unspecified d-axes default to 0. For rotation-aware effects, x_rotation filters pitch and y_rotation filters yaw.
Tags, Scores and Data-Driven Filters
For map-making, the most powerful filters are data-driven. tag reads custom tags set with /tag: @e[tag=marked] matches tagged entities, tag= matches entities with no tags, and multiple tag= arguments are ANDed. scores reads scoreboard objectives as ranges — @a[scores={hp=1..5,mana=10}]. Java-only filters include nbt (matches a subset of the entity’s NBT, e.g. @a[nbt={OnGround:true}]), team, advancements, and predicate. Note the nbt selector still reads entity NBT and was unaffected by the 1.20.5 move to item components — that change only altered item syntax like /give, not selector arguments.
How to Run These
- Chat: Press T or /, type the command with its leading slash (e.g.
/kill @e[type=zombie]), and press Enter. Here@sresolves to you. - Command block: Place a command block (obtained with
/give), enter the command without the slash, and power it. The block is not an entity, so@sselects nothing unless run through/execute as. - Server console: Type commands with no leading slash directly into the console. The console has no position or entity, so
@p/@eresolve relative to the world spawn context and@sselects nothing.
These selectors underpin nearly every command. See our full Minecraft commands list, the give command guide, the summon command guide, and teleport commands for real-world use. Running a server? XGamingServer Minecraft hosting gives you instant console access to test them.
Java vs Bedrock Differences
The five core variables exist in both editions, and @n (added during the 1.20.5 dev cycle) is available in Java and Bedrock too. The argument spellings differ, however. Java’s distance becomes Bedrock’s r (max) and rm (min); level becomes l/lm; x_rotation becomes rx/rxm; y_rotation becomes ry/rym; and gamemode becomes m (with shorthands s/0, c/1, a/2, d/5).
Bedrock has no sort keyword — it merges limit and sort into c, where a positive value takes the nearest N and a negative value the furthest N. Java-only arguments with no Bedrock equivalent are nbt, team, advancements, predicate and sort. Bedrock-only arguments include family, hasitem, has_property and haspermission. Coordinate handling differs too: Java x/y/z are not center-corrected, while Bedrock center-corrects integer coordinates. Education Edition adds @c and @v (agents), and @initiator exists in Bedrock/Education for NPC dialogue.
Frequently Asked Questions
What is the difference between @a and @e?
@a targets all online players including dead/respawning ones. @e targets all alive entities in loaded chunks — players, mobs, items and more — so it can include players but excludes anyone mid-respawn. Use @e[type=player] only when you specifically want the entity-based view.
Why does @p pick the “most recent” player in a tie?
@p defaults to sort=nearest, limit=1. If two players are exactly equidistant from the execution point, the tie-breaker is the one who joined the server most recently.
Can I target mobs with @p or @r?
Not in Java. @a, @p and @r always resolve to players, and type= cannot change their class. To target the nearest or a random non-player entity, use @n or @e with a type= filter and a sort. (In Java, @r can use type= for a random non-player entity specifically.)
How do I select entities within a specific area?
For a sphere, use distance: @e[distance=..10]. For a box, set an origin with x/y/z and a volume with dx/dy/dz: @e[x=0,y=64,z=0,dx=5,dy=3,dz=5] selects entities whose hitbox intersects that region.
Does @s work in a command block?
No — @s selects nothing when the executor is not an entity, which includes command blocks and the server console. To give a command block an entity executor, run it through /execute as @e[...] run ..., after which @s refers to that entity.
Related guides: target selectors overview, gamerules list, item IDs, keep inventory command, and the Minecraft enchantments list. Build any selector instantly with our Target Selector tool.
Ready to play?
Run your own Minecraft server with XGamingServer
Spin up an always-on Minecraft server your friends can join in minutes — no port-forwarding, no tech headaches.







