Empty fields are left out of the selector. Type a leading ! in any text field to negate it.
Matches every loaded entity: type zombie, within 10 blocks.
Removes every match instantly.
Teleports every match to the spot where the command runs.
Gives every match Speed II for 30 seconds.
Target selectors are the @ shortcuts Minecraft commands accept in place of a player name. @p targets the nearest player, @a all players, @r a random player, @e all entities and @s whoever runs the command; square-bracket arguments then filter those targets by type, position, score, gamemode and more.
Any command that asks for a target, such as /kill, /tp, /effect, /give or /execute, accepts a selector instead of a name. Without arguments a selector is broad: @e is every loaded entity in the world. The bracket arguments are what make selectors precise, narrowing thousands of potential targets down to exactly the zombies within 10 blocks, the players on one team, or the single nearest armor stand with a certain tag.
Selectors only resolve for command sources with permission: command blocks, datapack functions, the server console and players with operator rights (or cheats enabled in singleplayer). The generator above builds the selector string for you and shows it inside three real commands so you can paste something that works on the first try.
| Selector | Targets | Notes |
|---|---|---|
| @p | Nearest player | One player closest to where the command runs. Dead players are skipped. |
| @a | All players | Every player on the server, including dead players on the respawn screen. |
| @r | Random player | One player chosen at random; add limit to pick more than one. |
| @e | All entities | Every loaded entity that is alive: mobs, dropped items, projectiles, armor stands and players. |
| @n | Nearest entity | Shorthand for @e[limit=1,sort=nearest], available in newer Java versions. |
| @s | The executor | The single entity executing the command; with /execute as, that can be any entity. |
Arguments go in square brackets after the base, separated by commas: @e[type=zombie,distance=..10,limit=5]. Three patterns cover almost all of them. Ranges use min..max syntax, where either side can be left off. Negation puts ! in front of the value, and the negatable arguments (type, name, tag, team, gamemode, predicate, nbt) can be repeated with different negated values. Values with spaces, such as names, go in double quotes.
| Argument | What it filters | Example |
|---|---|---|
| type | Entity type id. Prefix with ! to exclude a type; repeat negated entries to exclude several. Not allowed on @p, @a or @r. | type=!minecraft:player |
| name | Custom name or player name. Quote it when it contains spaces; ! excludes a name. | name="Boss Mob" |
| tag | Scoreboard tag added with /tag. Repeat the argument to require several tags at once; tag=! excludes, and tag= alone matches entities with no tags. | tag=arena,tag=alive |
| team | Scoreboard team name. team= matches entities on no team, team=! matches anyone on any team. | team=red |
| gamemode | Player gamemode: survival, creative, adventure or spectator. ! negates. Only matches players. | gamemode=!creative |
| level | Experience level range in min..max form. Only matches players. | level=30.. |
| distance | Distance in blocks from the command's execution position, as a range. | distance=..10 |
| x, y, z | Override the point that distance and dx/dy/dz measure from. Plain numbers only; relative ~ coordinates do not work inside selectors. | x=100,y=64,z=-200 |
| dx, dy, dz | Selects entities whose hitbox touches the box stretching that many blocks from x y z along each axis. | dx=10,dy=5,dz=10 |
| x_rotation | Vertical look angle (pitch) range: -90 is straight up, 90 is straight down. | x_rotation=-10..10 |
| y_rotation | Horizontal look angle (yaw) range from -180 to 180, where 0 faces south. | y_rotation=-45..45 |
| scores | Scoreboard objective ranges inside braces. Every listed objective must match. | scores={kills=5..,deaths=0} |
| advancements | Advancement completion inside braces: true requires it done, false requires it not done. Individual criteria nest in inner braces. | advancements={story/form_obsidian=true} |
| nbt | Raw SNBT data the target must match, or must not match with !. | nbt={OnGround:true} |
| predicate | A datapack predicate the target must pass; ! inverts the test. | predicate=example:in_lava |
| limit | Caps how many targets the selector returns. Not allowed on @s or @n. | limit=3 |
| sort | Order applied before limit: nearest, furthest, random or arbitrary. | sort=nearest |
A few arguments only make sense for certain bases. type is rejected on @p, @a and @r because they always target players, and limit and sort are rejected on @s, which can only ever return the executor. The generator above warns you live when a combination will not run in game.
These five commands cover the selector patterns people reach for most. Paste them into chat (with operator permissions) or a command block, or rebuild them in the generator and tweak the numbers:
| Command | What it does |
|---|---|
| /kill @e[type=minecraft:item] | Clears every dropped item in loaded chunks. The classic lag cleanup. |
| /tp @a[team=red] 0 80 0 | Teleports every player on team red to the arena at 0 80 0. |
| /effect give @a[distance=..15] minecraft:regeneration 10 1 | Regeneration II for 10 seconds for every player within 15 blocks. |
| /gamemode survival @a[gamemode=adventure] | Puts every player currently in Adventure mode back into Survival. |
| /give @r[level=10..] minecraft:diamond 3 | Hands 3 diamonds to one random player at experience level 10 or higher. |
@p targets the single nearest player to wherever the command runs. Typed in chat, that is usually you; run from a command block, it is the player closest to the block. Arguments still apply, so @p[team=red] picks the nearest player on team red. Dead players are never selected by @p.
@a targets every player and only players, including dead players sitting on the respawn screen. @e targets every loaded entity: players, mobs, dropped items, arrows, armor stands and more, but only while they are alive. Add type=zombie or another type argument to narrow @e to one kind of entity.
@s targets the exact entity executing the command, whatever it is. In chat that is you; inside /execute as @e[...] run, @s becomes each entity that execute handed control to. It is also the cheapest selector because the game never has to search the world for a match.
Use @e[type=!minecraft:player]. The ! negates the type, so the selector matches every entity that is not a player. Be careful when pairing it with /kill: it also matches dropped items, item frames, armor stands and paintings, so add tags or more type filters when you only want hostile mobs.
It is a range. ..10 means 10 blocks or closer, 10.. means 10 blocks or farther, 5..10 means between 5 and 10 blocks, and a plain 10 means exactly 10 blocks from where the command runs. The same min..max syntax works for level, x_rotation, y_rotation and the score ranges inside scores={}.
The selector is valid but nothing matched it. The usual causes are a misspelled type or tag, a distance or dx/dy/dz box that does not reach the targets, gamemode or level filters applied to non-players, or a command block measuring distance from its own position instead of yours. Remove arguments one at a time until it matches, then re-add the rest.
Chain your selector into bigger commands, or browse more Minecraft tools: