Depending on the species of whale......each answer to that question is different.
Baleen Whales
Baleen types of whales...eat mostly small shrimp-like crustaceans called Krill which are only about 2 inches in length. Without these tiny Krill creatures - most life-forms in our oceans would disappear!
These tiny creatures are very plentiful, live for years and reproduce fast.
This makes the perfect food source for Baleen whales as well as literally hundreds of other different animals.
Krill are swarming animals - they swarm as a protective machination that confuses smaller predators from picking out individuals....as a result these dense "swarms" of krill are perfect for baleen whales to consume thousands in just one big gulp!
The Humpback whale not only eats Krill but also feeds on tiny fish such as sardines and herring by the ton...using a very unique and co-operative style as seen in THIS VIDEO BELOW!
Toothed Whales
What toothed types of whales eat depends on the species. Orca or killer whales have 2 species....they look identical but their diet and DNA make them distinctly different.
One species of Orca whale called "Transient Orca whales"....eats mammals and the other species called "Resident Orca whales" eat only fish.
"Toothed" whales use echolocation to hunt their food...sending out sonar-like signals (high frequency clicks) much like bats do to identify their prey.
Below is a short VIDEO ANIMATION depicting a Sperm whale using echolocation or sonar to hunt their favorite foods.....the colossal and the giant squid.
What appears to be laser-like beams coming from the Sperm whale are a series of sonar-like clicks that are (sounds only) that bounce off the surroundings and help him identify one food source from another.