Set changes the world's difficulty to the value you pick below.
Needs cheats enabled in singleplayer, or operator permission (level 2) on a server. The change applies to the whole world instantly and is saved with it.
/difficulty sets your Minecraft world to peaceful, easy, normal or hard, or tells you which one is active when you run it with no argument. It needs permission level 2: cheats in singleplayer, operator status or the console on a server.
Difficulty is a per-world setting that controls whether hostile mobs spawn, how hard they hit, and how dangerous hunger is. The command takes effect instantly across the whole world, including every dimension, and the new value is saved with the world, so it persists after you quit. Switching to peaceful despawns nearly all loaded hostile mobs on the spot; switching back lets fresh ones spawn again, but the despawned mobs are gone for good.
The command works anywhere commands run: the chat window, command blocks, functions and the dedicated server console. On a server the server.properties file also has a difficulty key that applies when the server starts; /difficulty is how you change the running world without a restart.
One detail worth knowing: the difficulty lock in the options screen only freezes the menu selector. The command ignores the lock, so a locked world can still be changed with /difficulty at any time.
The full Java Edition syntax tree is tiny: the bare command queries the current setting, and exactly four literal arguments set a new one.
The command requires permission level 2 (the gamemasters level): operators, command blocks, functions, the server console, or a singleplayer world with cheats enabled. There is no target selector and no extra argument; anything after the difficulty name is a syntax error.
Two quirks: setting the difficulty the world is already on fails with The difficulty did not change, and Java Edition has only accepted the four names since 1.13. Bedrock Edition additionally accepts the legacy numbers 0 to 3 and the single-letter aliases p, e, n and h.
The biggest lever is mob melee damage. On easy, damage is halved and then raised by one point (never above the base value); on hard it is multiplied by 1.5. Using the base attack values straight from the current game data, that works out to:
Damage is measured in health points, where two points equal one heart. Hunger scales the same direction: starvation stops at 10 HP on easy, at 1 HP on normal, and kills you outright on hard. Villagers killed by zombies convert to zombie villagers never on easy, half the time on normal and every time on hard, which matters a lot when defending a trading hall.
Hard adds threats that simply do not exist below it: zombies break wooden doors, zombies can summon reinforcements, spiders can spawn with potion effects, and raids run 7 waves instead of 5 (normal) or 3 (easy). Cave spider poison follows the same curve: none on easy, 7 seconds on normal, 15 seconds on hard.
Peaceful goes the other way entirely. Hostile mobs despawn and stop spawning (the ender dragon still appears in the End), the hunger bar never drains, and health regenerates quickly without food. It is the standard rescue move when you are about to die: open the pause menu, run /difficulty peaceful, and the mobs around you vanish.
Copy any of these into chat (with cheats or op permission) or into a command block without the leading slash:
/difficulty peaceful
Clears every loaded hostile mob, stops new ones from spawning and freezes the hunger bar. The fastest way to make a world safe.
/difficulty easy
Keeps hostile mobs but softens them: melee damage is roughly halved and starvation can never drop you below 10 HP.
/difficulty normal
The survival baseline. Mobs deal their listed damage and starvation stops at half a heart.
/difficulty hard
Mob melee damage rises to 1.5x, zombies break wooden doors and call reinforcements, and starvation can kill.
/difficulty
Changes nothing. Prints the world's current setting in chat, for example The difficulty is Normal.
Run /difficulty followed by peaceful, easy, normal or hard, for example /difficulty hard. The change applies to the whole world immediately and is saved with it, so it survives quitting and reloading. You need cheats enabled in singleplayer or operator permission on a server.
It queries the current setting instead of changing it. Chat replies with a line like The difficulty is Normal. The query form needs the same permission level 2 as the set form, so it works for operators, command blocks and the server console.
The command requires permission level 2 (gamemasters). In singleplayer that means the world must have cheats enabled; if it does not, open the world to LAN with Allow Cheats turned on. On a server you need to be an operator, or run the command from the server console, which always has permission.
Yes. The lock button in the options screen only disables the difficulty selector in that menu. The /difficulty command bypasses the lock and still changes the setting, which makes it the standard way to adjust a world after locking it.
Not on Java Edition. The numeric ids 0 to 3 were removed from the Java command in 1.13, so modern Java only accepts the four names. Bedrock Edition still accepts the numbers and the short aliases p, e, n and h alongside the full names.
No. Hardcore is a separate world flag that forces the difficulty to hard, locks it and removes respawning. You cannot switch it on or off with /difficulty; turning hardcore off means editing the world's level.dat, for example with our Hardcore World Reviver tool.
Tuning more world settings? Browse more Minecraft tools: