Energy flows through ecosystems from producers to consumers. Producers, such as plants, algae, and some bacteria, capture energy from the sun or chemicals and convert it into organic matter. Consumers, including herbivores, carnivores, omnivores, and decomposers, obtain energy by eating producers or other organisms. Energy is lost at each transfer between trophic levels as it flows through food chains and webs in an ecosystem.