How to Kill All Entities Except Players Using Commands

Published on

You want to clear lag entities but the /kill command wipes everything, including yourself. Here is how to target specific entity types using execute selectors without scoreboards or complex setups.

Written by Jochem Wassenaar – CEO of Space-Node – 15+ years combined experience in game server hosting, VPS infrastructure, and 24/7 streaming solutions. Read author bio →

minecraft kill entities except players command guide

Your server has 500 dropped items, 200 zombies, and a creeper army lagging the tick loop. You type /kill @e and everything dies. Including you. Including every player on the server.

The @e selector targets every entity. Players are entities too. You need a way to exclude specific types.


Kill Everything Except Players

/kill @e[type=!player]

The ! negates the type filter. This kills every entity that is NOT a player. Items, mobs, XP orbs, armor stands, minecarts. All gone. Players stay alive.


Kill Everything Except Players and Specific Mobs

You want to clear hostile mobs but keep the villagers and pets alive:

/kill @e[type=!player,type=!villager,type=!wolf,type=!cat]

You can stack multiple type=! filters. Each one adds another exception. This command kills every entity except players, villagers, wolves, and cats.


Kill Only Specific Types

Instead of exclusions, target specific types:

/kill @e[type=zombie]
/kill @e[type=item]
/kill @e[type=experience_orb]

This is safer because you know exactly what gets removed. No surprises.


Kill Entities in a Specific Area

Add location and distance parameters:

/kill @e[type=!player,x=100,y=64,z=200,distance=..50]

This kills all non-player entities within 50 blocks of coordinates X=100, Y=64, Z=200.

The distance=..50 means "from 0 to 50 blocks away." You can also set a minimum distance: distance=10..50 kills entities between 10 and 50 blocks away.


Using Command Blocks for Automated Cleanup

Place a repeating command block and set it to "Always Active":

/kill @e[type=item,nbt={Age:5000s}]

Wait. That does not work cleanly because item Age is tricky. A simpler approach:

/kill @e[type=item,nbt={PickupDelay:0s}]

This kills dropped items that have been on the ground long enough for the pickup delay to expire (items that nobody picked up).

For a lag cleanup command block, the most useful setup is:

Repeating Command Block (runs every tick):

/execute if entity @e[type=item,limit=200] run kill @e[type=item,sort=random,limit=100]

This checks if there are more than 200 item entities in the world. If yes, it kills 100 random items. This prevents item buildup from ever causing lag without removing items instantly after they drop.


Entity Types Reference

Here are the most common entity types you will target:

| Entity Type | What It Is | |---|---| | player | Real players | | item | Dropped items on the ground | | experience_orb | XP globes floating around | | zombie | Zombies (all variants) | | skeleton | Skeletons | | creeper | Creepers | | spider | Spiders | | armor_stand | Armor stands | | item_frame | Item frames | | minecart | All minecart types | | villager | Villagers | | wolf | Dogs/wolves | | cat | Cats | | arrow | Shot arrows stuck in blocks or flying |


The Wrong Way: Using r=0

Some old tutorials suggest using @e[r=0] to target entities at the exact command block location. This is outdated and unreliable. The r parameter was replaced with distance in Java Edition 1.13. If you see r=0 in a guide, it is written for a version from 2018 or older.

Use distance=0 or distance=..5 instead.


Command Block vs Plugin

For simple cleanup tasks, command blocks work fine. For sophisticated entity management on a server with many players, a plugin like ClearLagg handles entity removal with warnings, timers, and configurable exceptions. ClearLagg announces "Ground items will be cleared in 60 seconds" before removing them, giving players time to pick up dropped loot.

Install ClearLagg from SpigotMC: spigotmc.org/resources/clearlagg.68271/

On Space-Node servers, you get full command block support and the ability to install any cleanup plugin through the panel. Check the plans here.

Jochem Wassenaar

About the Author

Jochem Wassenaar – CEO of Space-Node – Experts in game server hosting, VPS infrastructure, and 24/7 streaming solutions with 15+ years combined experience.

Since 2023
500+ servers hosted
4.8/5 avg rating

Our team specializes in Minecraft, FiveM, Rust, and 24/7 streaming infrastructure, operating enterprise-grade AMD Ryzen 9 hardware in Netherlands datacenters. We maintain GDPR compliance and ISO 27001-aligned security standards.

View Space-Node's full team bio and credentials →

Start Minecraft Server in Minutes

Join content creators worldwide who trust our minecraft infrastructure. Setup is instant and support is always available.

How to Kill All Entities Except Players Using Commands