What is the command to kill all mobs?

I'm building a mini-game on a flat world and slimes are spawning on it. They keep setting off TNT and other traps, forcing me to rebuild every time.

What is a command that I can use to kill all mobs?


Solution 1:

Set the difficulty to peaceful in the options menu

Solution 2:

Type and enter /gamerule doMobSpawning false