Compasses in Minecraft work like compasses in the real world as long as players aren't in the Nether.
A compass in Minecraft can be a great tool for players that need a sense of direction. After a player makes a compass out of iron and Redstone, it can work similarly to one in the real world. The compass needle points north no matter what direction the player is standing.
Compasses in Minecraft
On the surface
While a player is on the surface of Minecraft, they can use a compass to navigate around their world. They can also add a compass to their map and create a locator map.
A locator map will show players where they are on the map and what direction they're facing. Locator maps can be made of a crafting table.
The red needle on a compass in Minecraft points north regardless of where the player is standing. If the red needle is pointed in the same direction the player is going, they're headed north.
If the red needle is pointed in the opposite direction the player is going in, they're headed south. The needle pointing to the right means the player is headed west. And the needle pointing to the left means the player is headed east.
In the Nether
When a player attempts to take a compass or a clock into the Nether, they behave differently. The compass needle points to several locations and does not stay still.
The red needle on a compass while in the Nether is constantly moving. The needle doesn't move in one direction as if the Nether is spinning under the player. Instead, the needle changes directions abruptly. Even if the player is completely still, the needle will not stop moving. The same can be said for the clock in Minecraft.