The study of molecules in space, known as astrochemistry or molecular astrophysics, is a rapidly growing field. Molecules exist in a wide range of environments in both gaseous and solid form, from our own solar system to the distant early universe. To astronomers, molecules are indispensable and unique probes of the physical conditions and dynamics of regions in which they are detected, especially the interstellar medium. In particular, the many stages of both low-mass and high-mass star formation are better understood today thanks to the analysis of molecular observations. Molecules can also yield a global picture of the past and present of sources. Moreover, molecules affect their environment by contributing to the heating and cooling processes that occur.