Updated:
Pick by goal
| Goal | Use |
|---|---|
| No hostile mobs at all | /difficulty peaceful |
| No new natural spawns, animals included | The mob spawning game rule |
| No phantoms only | The phantom game rule |
| Only around your base | Light, or /fillbiome (Java) |
Peaceful
/difficulty peaceful
Hostile mobs stop spawning and the ones already there disappear. Health regenerates on its own too, so the game plays differently. See the difficulty guide.
Game rules
| Stops | Java 1.21.11+ | Java 1.21.10 and earlier | Bedrock |
|---|---|---|---|
| Natural mob spawning (animals too) | minecraft:spawn_mobs | doMobSpawning | domobspawning |
| Phantoms | minecraft:spawn_phantoms | doInsomnia | doinsomnia |
/gamerule minecraft:spawn_mobs false
That is the 1.21.11+ form. Turning off mob spawning also stops new animals. Spawners keep working, so mob farms built on spawners still run. Mobs already in the world stay, so clear them as shown below.
Phantoms appear at night when you have not slept for a while. Turning off only the phantom rule leaves every other mob as normal.
Clear the mobs already there
/kill @e[type=minecraft:zombie]
/kill @e[type=minecraft:creeper,distance=..50]
Name the mob type. A bare /kill @e also removes players, pets and armor stands. The easiest way is to switch to Peaceful for a moment and then back. See the kill guide.
Only around your base
- Light it up: most hostile mobs spawn only where the block light level is 0 (Java 1.18+). Torches around your base stop spawns there.
- Mushroom fields (Java): hostile mobs do not spawn naturally in
mushroom_fields. Turn your base area into that biome with /fillbiome.
When it does not work
- Mobs are still around: game rules only stop new spawns. Clear the existing ones.
- Mobs come from a spawner: spawners ignore the game rule. Break it or light it up.
- Error on 1.21.11+: the game rule names changed. Use the new names above.
Common questions
- Peaceful or the game rule? Peaceful is quickest if you just want no hostile mobs. Use the game rule to keep your difficulty or to stop animals too.
- Does it stop raids? Peaceful does. The mob spawning rule may not, because raids work differently.
- Peaceful for a whole server? Set
difficulty=peacefulin server.properties.
Check your command
The Command Error Doctor checks common syntax mistakes in your browser.