Compass

Compasses are an item used to point to the world spawn. They are crafted using 4 iron ingots and one piece of redstone dust.

Trading
Expert-level librarian villagers have a 50% chance to sell a single compass for 4 emeralds.

Expert-level librarian villagers have a $1/3$ chance to sell a single compass for 4 emeralds.

Usage
Normally, the compass' needle points toward the world spawn point; more specifically, it always points toward the northwest corner of the block whose coordinates are set as the world spawn. The compass points to spawn when viewed in any way, including as a dropped item, in a player's hand, in an inventory or the crafting table, or in an item frame. The compass that is shown on the topmost tab of the recipe book also points to spawn. The direction the needle points is relative to the player who is viewing it.

In the Nether or the End, the compass' needle spins and points in random directions.

, the compass can be used on a lodestone in any dimension, creating a lodestone compass storing the lodestone's dimension type and position. While the world the player is in has the same type as stored, it points to the stored position, however, if at one point the compass finds out a lodestone is no longer present at the position stored, it reverts to a normal compass. If the dimension type doesn't match, the compass spins randomly.

Trading
A single compass can be sold to a journeyman-level cartographer villager for 1 emerald.

A single compass can be sold to an expert-level cartographer villager for 1 emerald as their sixth trade. A compass is also part of the cost of explorer maps:

An ocean explorer map or a woodland explorer map can be bought from a journeyman-level cartographer for 12 emeralds and a compass, as part of their fifth trade.

In Java Edition, apprentice-level Cartographer villagers offer to sell an ocean explorer map for 13 emeralds and a compass, and journeyman-level Cartographer villagers offer to sell a woodland explorer map for 14 emeralds and a compass.

Video
Note: This video is outdated as it does not mention anything about the lodestone compass.

Trivia

 * A compass can be viewed under the item statistics page, as long as one has made a compass at some point in the past. It can also be viewed in the recipe book as the search tab's icon, or when the recipe for it if it has been unlocked.
 * Using to change the world spawn also changes where the compass points.