Photosynthesis is the process by which plants, algae, and some bacteria use sunlight, water and carbon dioxide to produce oxygen and energy in the form of glucose. It occurs in two stages: in the light-dependent reactions, sunlight is absorbed and used to convert carbon dioxide and water into glucose, producing oxygen as a byproduct. In the light-independent reactions, the glucose is then assembled from carbon dioxide using energy from the light reactions. The light reactions take place in chloroplasts within plant cells, while the dark reactions occur in the chloroplast stroma. Photosynthesis is essential for producing oxygen and food on Earth.