Frogs inhabit a variety of different habitats and have a diverse array of predators and prey, but most frogs fill the small, ectothermic, insectivorous niche. Some frogs fill this niche in terrestrial ecosystems, but others do so in aquatic or arboreal habitats. Because they consume many small invertebrates and are themselves food for many small- and medium-sized predators, frogs are very important components of the ecosystems in which they live.
Frogs that live in aquatic habitats generally consume insects and other aquatic invertebrates, such as crawfish. Additionally, large aquatic frogs often eat fish and other frog species. Snakes, predatory fish and raccoons, among other predators, predate upon aquatic frogs.
Some frog species have left the ancestral aquatic habitat and ventured into terrestrial and arboreal ones. This changes their ecological niche slightly, as they encounter different predators and prey. Most terrestrial frogs consume large terrestrial insects, such as roaches and beetles; however, some species, such as narrow-mouthed toads, specialize on small insects, such as ants and termites.
Arboreal frog species tend to eat flying insects common in their treetop habitats. Both terrestrial and arboreal frogs must avoid similar predators, including medium-sized birds, snakes, bats, foxes, opossums, and domestic dogs and cats.