During development, cardiogenesis is orchestrated by a family of heart progenitors that build distinct regions of the heart. Each region contains diverse cell types that assemble to form the complex structures of the individual cardiac compartments. Cardiomyocytes are the main cell type found in the heart and ensure contraction of the chambers and efficient blood flow throughout the body. Injury to the cardiac muscle often leads to heart failure due to the loss of a large number of cardiomyocytes and its limited intrinsic capacity to regenerate the damaged tissue, making it one of the leading causes of morbidity and mortality worldwide. In this Primer we discuss how insights into the molecular and cellular framework underlying cardiac development can be used to guide the in vitro specification of cardiomyocytes, whether by directed differentiation of pluripotent stem cells or via direct lineage conversion. Additional strategies to generate cardiomyocytes in situ, such as reactivation of endogenous cardiac progenitors and induction of cardiomyocyte proliferation, will also be discussed.