Tutorials/Iron golem farming

Iron golem farming uses village mechanics to produce iron, as well as byproducts such as poppies and string. Usually, an iron golem farm is a player-constructed village in which golems are spawned and then either killed immediately, or moved to a holding cell outside the village boundary for later killing.

Java Edition
In Java Edition, a villager may attempt to spawn an iron golem after "talking" to 10 other villagers. The villagers must have access to their workspace and have slept before the golem will spawn, however.

Java Edition iron farm mechanics
Iron golems can spawn when non-nitwit villagers who have slept in beds gossip five times about needing a golem at a gathering point, and four other villagers are within 80 blocks. Once these conditions are met, an iron golem can spawn in a 16×6×16 area centered on the location of the villager who spread the gossip.

Bedrock Edition
In Bedrock Edition, villagers are not required to sleep or have a workstation in order to spawn iron golems. For an iron golem to spawn, the following conditions must be met:
 * The village has at least 21 beds
 * The village has at least 10 villagers, each of whom has claimed a bed
 * The villagers can interact with one another

Bedrock Edition iron farm mechanics
The spawning area is a 16×4×1 region centered around each bed; that is, the spawning area extends 7 blocks from the head and 7 blocks from the foot of the bed, 2 blocks below, and 1 block above the bed. Multiple beds create more spawn volume; for example 10 beds side-by-side create a 16×4×10 spawn volume. The foot of the golem will spawn in this region. The golem, being nearly 3 blocks tall, needs sufficient air space above the foot to allow it to move.

If there is no solid surface with sufficient air space above to spawn on within this volume, the iron golem won't spawn. This means, for example:
 * Beds placed in a row with the head or foot against a cliff face will create a spawning region on one end of the beds only, because golems won't spawn inside the solid blocks in the region on the other end.
 * Beds placed 3 or more blocks above ground will cause iron golems to spawn on a platform within the spawning region, and not on the ground.
 * Because iron golems won't spawn on slabs, slabs may be strategically placed to restrict the spawning area (possibly at the expense of spawn probability).