
The Giant's Causeway in County Antrim, Northern Ireland, formed when basalt lava cooled, shrank and cracked. The long columns are pieces of rock left between those fractures. Geologists call a fracture a joint, and this pattern is known as columnar jointing. The British Geological Survey describes the volcanic origin.
A lava flow that split as it cooled
The Causeway's basalt belongs to volcanic activity that accompanied the opening of the North Atlantic. The British Geological Survey describes several early eruptions, followed by a long dormant interval. Weathering altered the old lava surface, leaving a red layer between earlier and later flows, while erosion cut valleys into it. Later lava collected in an old valley, forming a thick body of rock. As it lost heat, contraction pulled the rock apart.
The cracks developed in solid rock. In a 2018 laboratory study using Icelandic basalt, University of Liverpool researchers found that the rock fractured after solidifying, while it was still hot. The experiment helps explain how cooling can split basalt; its results are not measurements of the ancient Causeway flow.
Cracks can grow inward from the top and bottom of a cooling body of rock. Columns form roughly perpendicular to those cooling surfaces, at about a right angle to them. Their long sides follow the direction in which the fractures extend, according to the National Park Service.

Why the tops often have six sides
A column's top shows a polygon: a many-sided shape outlined by the surrounding cracks. Three cracks often meet at angles close to 120 degrees. This arrangement relieves the stress caused by contraction and commonly produces six-sided shapes, according to the National Park Service's explanation of joint geometry.
Columnar joints can also produce polygons with other numbers of sides, and the shapes need not be regular. The National Park Service describes columns with three to seven sides across columnar-jointing formations. That range describes the general process, rather than a count of the stones at the Causeway.

How the columns came into view
Further eruptions added upper basalt flows. After the columns formed, erosion brought them into view. The National Trust describes how Ice Age glaciers removed upper layers of rock. Later, waves exposed more columns as sea levels rose.