Updated:

Summon a mob that does not move (Java)

/summon minecraft:zombie ~ ~ ~ {NoAI:1b}

With NoAI:1b the mob does not walk, chase or attack, and keeps facing the same way, so it works like a statue.

Tags that go well with it

TagEffect
NoAI:1bNo movement or attacks
PersistenceRequired:1bDoes not despawn
Silent:1bMakes no sounds
Invulnerable:1bTakes no damage
/summon minecraft:villager ~ ~ ~ {NoAI:1b,PersistenceRequired:1b,Silent:1b,Invulnerable:1b}

This villager stays put, never despawns, stays quiet and cannot be killed. NoAI villagers can still trade, which makes them good shopkeepers. See the villager shop guide for custom trades.

Freeze a mob that is already there (Java)

/data merge entity @e[type=minecraft:villager,limit=1,sort=nearest] {NoAI:1b}

This freezes the nearest villager. Without limit=1,sort=nearest, every matching villager stops. See the data command guide.

Undo it

/data merge entity @e[type=minecraft:villager,limit=1,sort=nearest] {NoAI:0b}

Bedrock Edition

Bedrock commands have no NoAI. A very strong Slowness effect stops most walking:

/effect @e[type=villager,r=5] slowness 99999 255 true

The mob can still turn and attack, so it is not a full statue. For displays, an armor stand with equipment is another option.

When it does not work

Common questions

Check your command

The Command Error Doctor checks common syntax mistakes in your browser.