How To Kill All Entities Except Players In Minecraft: Complete Command Guide
Executing an entity purge in Minecraft requires precise target selector arguments to prevent unintended asset loss or world corruption. The fundamental command to eradicate all non-player entities while insulating online users is /kill @e[type=!player] across both Java Edition and Bedrock Edition. Mastering logical negation filters, dimensional parameters, and specific entity exclusions allows server administrators to eliminate performance-degrading lag while preserving armor stands, item frames, and tamed mobs.
Pre-Execution Server Setup and Administrative Prerequisites
Before executing global elimination commands, server operators and map creators must prepare the environment to prevent catastrophic loss of build infrastructure, utility entities, or player pets. Mass entity purging operates instantaneously across all active chunks, meaning an unrefined target selector will destroy decorational and functional entities indiscriminately.
Essential Tools & Environment
- Operator Privileges: Level 2 Operator status on Java Edition servers or Cheats Enabled setting on Bedrock Edition worlds.
- Access Interface: Active in-game chat interface, a dedicated Command Block, or an external server console (RCON).
- Backup Utility: Native world save functionality, automated backup plugins like CoreProtect, or direct server directory archiving tools.
Mandatory Knowledge & Prerequisites
- Target Selector Mechanics: Familiarity with the universal entity selector @e and selector modification parameters enclosed in square brackets.
- Exclusion Logic: Understanding the exclamation mark logical negation operator (!), which instructs the command parser to target everything except the specified value.
- Entity Type Nomenclatures: Awareness that entities include not only hostile and passive mobs, but also dropped items, arrows, armor stands, item frames, boats, and minecarts.
Operational Benchmarks
- Estimated Execution Time: Under 1 second for instant chat execution; recurring execution intervals of 6,000 to 12,000 ticks (5 to 10 minutes) for automated setups.
- Target Server TPS Restoration: Ideal recovery from sub-15 Ticks Per Second (TPS) back to the standard 20.0 TPS benchmark following mass mob removal.
Executing Safe and Targeted Entity Purges Step-by-Step
Step 1: Secure Operator Privileges and Create World Backups
Before running destructive commands, ensure your account possesses administrative rights and that the world state is cached.
- On a single-player world, open the game menu, select Open to LAN, toggle Allow Cheats to ON, and click Start LAN World. On a multiplayer server, enter /op yourusername directly into the server host console.
- Force an immediate hard drive save of the current world state by typing /save-all in the server chat or console.
- If running a dedicated server, create a fast directory snapshot or backup of the world region files before issuing any global target commands.
Warning: Executing an unedited /kill @e command without target parameters will instantly kill all online players, clear all inventory drops, and destroy every item frame, painting, and armor stand in loaded chunks. Always double-check parameter syntax before pressing enter.
Step 2: Formulate the Basic Non-Player Target Selector Logic
The central component of targeting non-player entities lies in combining the universal entity target selector with a logical NOT operator applied to the player entity type.
- Open the chat console by pressing the default key T or the forward slash key / on your keyboard.
- Enter the foundational purge command string: /kill @e[type=!player]
- Analyze the syntax structure: the /kill command initiates entity deletion, @e calls all loaded entities, square brackets denote filtering conditions, type= specifies the class parameter, and !player excludes human players from the target group.
Step 3: Layer Safeguards to Protect Valued Non-Player Entities
A basic non-player wipe will permanently delete structural decoration entities, minecarts, dropped items, and tamed animals. To refine the command, chain multiple negative arguments inside the selector brackets separated by commas.
- To protect armor stands from being destroyed during a mob clear, append the armor stand exclusion filter: /kill @e[type=!player,type=!armor_stand]
- To protect dropped items on the floor that players may need to recover, add the item exclusion tag: /kill @e[type=!player,type=!item]
- To safeguard decorative item frames and paintings, expand the parameter set: /kill @e[type=!player,type=!armor_stand,type=!item_frame,type=!painting]
- To exclude named pets or custom NPCs, incorporate tag or name exclusions: /kill @e[type=!player,name=!GuardMob,type=!cat,type=!wolf]
Pro-Tip: Target selector filters evaluate every single argument synchronously. In Java Edition, you can chain multiple type=! parameters in a single command string. In Bedrock Edition, parameter chaining is fully supported in current releases, but testing in a single-player world is recommended prior to live deployment.
Step 4: Execute the Purge Command in Chat or Command Blocks
Depending on whether you require an immediate manual server cleanup or an automated recurring task, choose the appropriate deployment vector.
- For a manual, one-time immediate purge, simply paste the refined command string into your active in-game chat bar and press Enter.
- For automated execution, obtain a command block by typing /give @p command_block in the chat console.
- Place the command block in a permanently loaded chunk or inside a spawn chunk zone.
- Right-click the command block to open its interface. Set the Block Type to Repeat, set Redstone to Always Active, and input your precise command string into the Command Input field.
- Set the Delay in Ticks field to 6000 if you wish to run the sweep automatically every 5 minutes (20 ticks = 1 second).
Step 5: Establish Automated Chunk-Safe Clearing Cycles
To avoid unnecessary server CPU strain caused by running entity sweeps every tick, configure your command block architecture with radius limiters or tick throttles.
- Add a spatial bounding sphere using the distance or radius parameter to limit the sweep to heavily lagged areas, such as a mob farm: /kill @e[type=!player,distance=..64] in Java Edition, or /kill @e[type=!player,r=64] in Bedrock Edition.
- Test the restricted zone by placing non-hostile entities inside and outside the threshold, verifying that entities beyond the 64-block radius remain completely unaffected.
Minecraft Bedrock Edition how to kill all entities
Target Selector Syntax and Component Exclusion Matrix
Selecting the appropriate parameters prevents catastrophic asset deletion while targeting server lag sources. The table below details critical selector arguments, compatibility variations between game editions, and their specific administrative use cases.
| Command Component / Selector | Target Logic & Mechanism | Platform Availability | Primary Administrative Use Case | Server Performance Risk Level |
|---|---|---|---|---|
| @e[type=!player] | Targets every entity except active human players | Java & Bedrock Editions | Universal mob purge and immediate lag emergency fix | High (Wipes item frames, armor stands, and dropped items) |
| type=!item | Excludes dropped ground items from execution | Java & Bedrock Editions | Preserving player loot while eradicating hostile mobs | Low (Leaves dropped items intact; requires secondary item sweep) |
| type=!armor_stand | Excludes armor stands from execution | Java & Bedrock Editions | Protecting decorative armor displays in player builds | Very Low (Essential safety flag for creative & survival servers) |
| distance=..50 | Limits targeting to a 50-block spherical radius | Java Edition Only | Localized farm cleanup without wiping global world entities | Zero (Restricts execution to active local processing zone) |
| r=50 | Limits targeting to a 50-block spherical radius | Bedrock Edition Only | Localized farm cleanup without wiping global world entities | Zero (Restricts execution to active local processing zone) |
| family=!mob | Excludes specified entity family classifications | Bedrock Edition Only | Complex filter targeting custom entity groupings | Low (Advanced filtering method unique to Bedrock NBT architecture) |
| limit=100 | Caps total processed target entities to 100 units | Java Edition Only | Throttled sequential deletion to prevent CPU execution spikes | Very Low (Staggers processing load over multiple command cycles) |
Common Entity Purge Failures and Administrative Remedies
Decorative Infrastructure Wiped Post-Purge
- Root Cause: Running /kill @e[type=!player] without specifying structural entity exclusions. Minecraft classifies non-living entities like armor stands, item frames, paintings, minecarts, and end crystals as standard entities under the @e selector.
- Actionable Fix: Immediately restore the world from the pre-execution backup created in Step 1. Modify all future purge commands to explicitly list structural exclusions by utilizing the string: /kill @e[type=!player,type=!armor_stand,type=!item_frame,type=!painting,type=!glow_item_frame,type=!minecart].
Server Ticks Per Second (TPS) Drops Drastically During Purge
- Root Cause: Killing thousands of mobs simultaneously causes them all to drop experience orbs and loot items on the exact same tick, multiplying the total server entity count instead of reducing it.
- Actionable Fix: Disable mob loot drops temporarily before issuing the kill command by executing /gamerule doMobLoot false. Once the entity purge command is run, execute /kill @e[type=item] to remove any residual dropped items, then restore normal gameplay drops by entering /gamerule doMobLoot true.
Target Selector Fails on Bedrock Edition
- Root Cause: Attempting to use Java-specific target parameters (such as distance=..30) on Bedrock Edition, or placing spaces between selector arguments inside the square brackets.
- Actionable Fix: Replace Java parameters with Bedrock equivalents. Convert distance=..30 to r=30. Remove all spaces within the bracketed selector arguments, ensuring the string reads continuously without breaks, such as /kill @e[type=!player,type=!item].
Command Execution Misses Lagging Entities in Faraway Regions
- Root Cause: Minecraft only processes entities located within active, loaded chunks. Mobs trapped in unrendered chunks or non-tickable dimensions (such as unloaded Nether portals) bypass global kill commands.
- Actionable Fix: On Java Edition servers, set up temporary ticking areas using the /forceload add XZ XZ command over the affected coordinates before executing the kill script. On Bedrock Edition, establish a persistent chunk zone using /tickingarea add circle X Y Z 4 PurgeZone, execute the purge, and subsequently remove the ticking area.
Frequently Asked Questions
How do I kill all mobs except players and pets in Minecraft?
To spare tamed animals like wolves and cats while eradicating all other entities, extend your logical negation filters. Execute the command /kill @e[type=!player,type=!wolf,type=!cat,type=!parrot,type=!horse] in chat. This guarantees that registered companion animals remain unaffected while clearing wild passive mobs, hostiles, and unwanted entities.
Does the command /kill @e[type=!player] clear dropped items?
Yes, dropped items on the ground are categorized as individual entities of the item type. Executing a basic non-player purge will delete every item sitting on the floor across all loaded chunks. To protect dropped items, modify your target selector string to read /kill @e[type=!player,type=!item].
How do I restrict the entity kill command to a specific area?
You can constrain the execution radius by using distance parameters in Java Edition or radius parameters in Bedrock Edition. In Java Edition, type /kill @e[type=!player,distance=..30] to target entities within 30 blocks of the caller. In Bedrock Edition, execute /kill @e[type=!player,r=30] to achieve the identical localized boundary effect.
Can I run this command in a repeating command block without causing lag?
Running an unthrottled repeating command block every single tick (20 times per second) causes significant CPU load because the engine constantly scans all loaded entity arrays. To automate cleanups safely, set the Delay in Ticks setting inside the repeating command block interface to 6000 (a 5-minute delay) or 12000 (a 10-minute delay).
What is the difference between entity selectors in Java and Bedrock Edition?
While basic selectors like @e[type=!player] function identically across both platforms, specific syntax parameters diverge. Java Edition uses distance=min..max, limit=number, and allows multiple type=! arguments natively. Bedrock Edition utilizes r=radius, c=count for target limits, and uses entity family tags like family=!mob for broader mob category filtering.
Optimize Your Server Performance Today
Maintaining a high-performing Minecraft server requires balancing entity density with system resources. Utilize these refined target selector strings in your automated maintenance command blocks to keep your Ticks Per Second optimal while keeping your players and custom builds safe.