Start with Carbon
Understanding the chemistry of a diamond requires a basic knowledge of the element carbon. A neutral carbon atom has 6 protons and 6 neutrons in its nucleus, balanced by 6 electrons. The electron shell configuration of carbon is 1s22s22p2. Carbon has a valence of 4, since 4 electrons can be accepted to fill the 2p orbital. Diamond is made up of repeating units of carbon atoms joined to four other carbon atoms via the strongest chemical linkage, covalent bonds. Each carbon atom is in a rigid tetrahedral network where it is equidistant from its neighboring carbon atoms. The structural unit of diamond consists of 8 atoms, fundamentally arranged in a cube. This network is very stable and rigid, which is why diamonds are so very hard and have a high melting point.
Virtually all carbon on Earth comes from the stars. Studying the isotopic ratio of the carbon in a diamond makes it possible to trace the history of the carbon. For example, at the earth's surface the ratio of isotopes carbon-12 and carbon-13 is slightly different from that of star dust. Also, certain biological processes actively sort carbon isotopes according to mass, so the isotopic ratio of carbon that has been in living things is different from that of the Earth or the stars. Thus it is known that the carbon for most natural diamonds comes most recently from the mantle, but the carbon for a few diamonds is recycled carbon of microorganisms, formed into diamonds by the earth's crust via plate tectonics. Some minute diamonds that are generated by meteorites are from carbon available at the site of impact; some diamond crystals within meteorites are still fresh from the stars.
The crystal structure of a diamond is a face-centered cubic or FCC lattice. Each carbon atom joins four other carbon atoms in regular tetrahedrons (triangular prisms). Based on the cubic form and its highly symmetrical arrangement of atoms, diamond crystals can develop into several different shapes, known as 'crystal habits'. The most common crystal habit is the eight-sided octahedron or diamond shape. Diamond crystals can also form cubes, dodecahedra, and combinations of these shapes. Except for two shape classes, these structures are manifestations of the cubic crystal system. One exception is the flat form called a macle, which is really a composite crystal, and the other exception is the class of etched crystals, which have rounded surfaces and may have elongated shapes. Real diamond crystals don't have completely smooth faces, but may have raised or indented triangular growths called 'trigons'. Diamonds have perfect cleavage in four different directions, meaning a diamond will separate neatly along these directions rather than break in a jagged manner. The lines of cleavage result from the diamond crystal having fewer chemical bonds along the plane of its octahedral face than in other directions. Diamond cutters take advantage of lines of cleavage to facet gemstones.
Graphite is only a few electron volts more stable than diamond, but the activation barrier for conversion requires almost as much energy as destroying the entire lattice and rebuilding it. Therefore, once diamond is formed, it will not reconvert back to graphite because the barrier is too high. Diamonds are said to be metastable, since they are kinetically rather than thermodynamically stable. Under the high pressure and temperature conditions needed to form diamond its form is actually more stable than graphite, and so over millions of years carbonaceous deposits may slowly crystallize into diamond.