A coffee seed, commonly called coffee bean, is a seed of the coffee plant, and is the source for coffee. It is the pit inside the red or purple fruit often referred to as a cherry. Just like ordinary cherries, the coffee fruit is also a so-called stone fruit. Even though the coffee beans are seeds, they are referred to as "beans" because of their resemblance to true beans. The fruits – coffee cherries or coffee berries – most commonly contain two stones with their flat sides together. A small percentage of cherries contain a single seed, instead of the usual two. This is called a "peaberry". The peaberry occurs only between 10 and 15% of the time, and it is a fairly common (yet scientifically unproven) belief that they have more flavour than normal coffee beans. Like Brazil nuts (a seed) and white rice, coffee beans consist mostly of endosperm.

The two most economically important varieties of coffee plant are the Arabica and the Robusta; 75–80% of the coffee produced worldwide is Arabica and 20% is Robusta. Arabica beans consist of 0.8–1.4% caffeine and Robusta beans consist of 1.7–4% caffeine. As coffee is one of the world's most widely consumed beverages, coffee beans are a major cash crop and an important export product, counting for over 50% of some developing nations' foreign exchange earnings

The coffea tree averages from 5–10 m (16–33 ft) in height. As the tree gets older, it branches less and less and bears more leaves and fruits.

Coffea plants are grown in rows several feet apart. Some farmers plant fruit trees around them or plant the coffee on the sides of hills, because they need specific conditions to flourish. Ideally, Arabica coffee beans are grown at temperatures between 15 and 24 °C (59 and 75 °F) and Robusta at 24–30 °C (75–86 °F) and receive between 15 and 30 cm (5.9 and 11.8 in) of rainfall per year. Heavy rain is needed in the beginning of the season when the fruit is developing and less later in the season as it ripens.

Caffeine (1,3,7-trimethyl-xanthine) is the alkaloid most present in green and roasted coffee beans. The content of caffeine is between 1.0% and 2.5% by weight of dry green coffee beans. The content of caffeine does not change during maturation of green coffee beans. Lower concentrations of theophylline, theobromine, paraxanthine, liberine, and methylliberine can be found. The concentration of theophylline, an alkaloid noted for its presence in green tea, is reduced during the roasting process, usually about 15 minutes at 230 °C (446 °F), whereas the concentrations of most other alkaloids are not changed. The solubility of caffeine in water increases with temperature and with the addition of chlorogenic acids, citric acid, or tartaric acid, all of which are present in green coffee beans. For example, 1 g (0.035 oz) of caffeine dissolves in 46 ml (1.6 US fl oz) of water at room temperature, and 5.5 ml (0.19 US fl oz) at 80 °C (176 °F). The xanthine alkaloids are odorless, but have a bitter taste in water, which is masked by organic acids present in green coffee, however.

Trigonelline (N-methyl-nicotinate) is a derivative of vitamin B6 that is not as bitter as caffeine. In green coffee beans, the content is between 0.6% and 1.0%. At a roasting temperature of 230 °C (446 °F), 85% of the trigonelline is degraded to nicotinic acid, leaving small amounts of the unchanged molecule in the roasted beans. In green coffee beans, trigonelline is synthesized from nicotinic acid (pyridinium-3-carboxylic acid) by methylation from methionine, a sulfur-containing amino acid. Mutagenic activity of trigonelline has been reported

The lipids found in green coffee include: linoleic acid, palmitic acid, oleic acid, stearic acid, arachidic acid, diterpenes, triglycerides, unsaturated long-chain fatty acids, esters, and amides. The total content of lipids in dried green coffee is between 11.7 and 14 g/100 g. Lipids are present on the surface and in the interior matrix of green coffee beans. On the surface, they include derivatives of carboxylic acid-5-hydroxytryptamides with an amide bond to fatty acids (unsaturated C6 to C24) making up to 3% of total lipid content or 1200 to 1400 microgram/g dried green coffee bean. Such compounds form a wax-like cover on the surface of the coffee bean (200 to 300 mg lipids/100 g dried green coffee bean) protecting the interior matrix against oxidation and insects. Further, such molecules have antioxidative activity due to their chemical structure. Lipids of the interior tissue are triglycerides, linoleic acid (46% of total free lipids), palmitic acid (30% to 35% of total free lipids), and esters. Arabica beans have a higher content of lipids (13.5 to 17.4 g lipids/100 g dried green coffee beans) than robustas (9.8 to 10.7 g lipids/100 g dried green coffee beans). The content of diterpenes is about 20% of the lipid fraction. The diterpenes found in green coffee include cafestol, kahweol, 16-O-methylcafestol, cafestal and kahweal. Some of these diterpenes have been shown in in vitro experiments to protect liver tissue against chemical oxidation. In coffee oil from green coffee beans the diterpenes are esterified with saturated long chain fatty acids.