NapNodes
Free tool · Minecraft Java

Minecraft target selector generator

Pick who the command is for (every player, the zombies within 20 blocks, the player tagged «boss»…) and get the selector written right, with what it picks in plain English and a warning if it's about to catch something you didn't want.

Tags, team, level, score and area · optional
@e[type=zombie,distance=..20]

Picks: All entities of type “Zombie”, 20 blocks away or less.

In the panel's “Console” the command doesn't come from you: distances and “the nearest” aren't measured from where you stand. There, use the player's name instead.

To use it (in chat, with the slash; in the console, without it):

  • /effect give @e[type=zombie,distance=..20] minecraft:glowing 10
  • /tp @e[type=zombie,distance=..20] @s
  • /kill @e[type=zombie,distance=..20]
  • /execute as @e[type=zombie,distance=..20] at @s run particle minecraft:heart ~ ~2 ~

The six selectors

  • @a: every player online.
  • @p: the player nearest to where the command runs (with limit=3, the three nearest).
  • @r: a random player.
  • @s: whoever runs the command. In chat, you; inside an /execute as, each entity in turn.
  • @e: every entity. Players included, and it's the one that causes the most accidents.
  • @n: the nearest entity, since 1.21.

The most used arguments

They go in square brackets, separated by commas and without spaces: @e[type=zombie,distance=..20,limit=5,sort=nearest]. All of them have to be true at once.

  • type: the entity type, by its ID (zombie, item, villager). With ! in front, all but that one: type=!player. Not used in @a, @p and @r, which are already players.
  • distance: the distance in blocks, as a range (..10, 5.., 5..10).
  • limit and sort: how many at most and in what order (nearest, furthest, random or arbitrary).
  • name: the exact name; with spaces, in quotes.
  • tag: the tags you add with /tag Name add boss. You can use several and all must match; tag=!boss means «without that tag».
  • team, gamemode, level and scores: team, game mode, experience level and scoreboard scores.
  • x, y, z and dx, dy, dz: a box in the world, from one corner and with its size.

They're what the commands in the Minecraft admin commands guide are written with, and the ones in the other tools, like the /give generator or the /tellraw generator. On a NapNodes server, commands go in «Console» (without the slash).

Frequently asked questions

What's the difference between @a, @p, @r, @s, @e and @n?

@a is every player; @p, the nearest player; @r, a random one; @s, whoever runs the command; @e, every entity (mobs, dropped items, arrows… and players); and @n, the nearest entity of any kind (added in 1.21).

How do I kill all mobs without killing the players?

With /kill @e[type=!player]. Careful: that also removes dropped items, paintings, armor stands and boats. If you only want one type, say so: /kill @e[type=zombie]. Before removing anything, test the selector with /effect give … minecraft:glowing 10 and you'll see what it picks.

How do I write a name with spaces?

In quotes: @e[name="My horse"]. The name has to be exact, capital letters included. The generator only adds the quotes when they're needed.

What do the two dots in distance=..10 mean?

They're a range: ..10 is «10 or less», 5.. is «5 or more» and 5..10 is «from 5 to 10». The same goes for level and scores.

Why doesn't @s or @p work in the console?

Because in the server console nobody is behind the command: @s finds no one and «the nearest» isn't measured from you. In the console, type the player's name; selectors with a distance work better from chat or a command block.

Does it work on Bedrock?

The idea is the same, but Bedrock uses other arguments (r and rm instead of distance, c instead of limit). This tool writes the Java ones, which is what Paper servers run.

No server yet?

At NapNodes you get a free Minecraft server, no card needed, with the panel «Console» to type these commands. And if you want to play with no queues and the server always on, plans have their RAM reserved just for you and each machine's load in view on the status page.

Create your free server

More free tools

All the tools