Crocodilians today are fearsome meat-eating reptiles, but new research shows that wasn't always the case.

Turns out some of the ancestors of crocodiles and alligators had a preference for a vegetarianism that was hard to shake.

"Our work demonstrates that extinct crocodyliforms had an incredibly varied diet," lead author of the new study, University of Utah geobiologist Keegan Melstrom explains.

"Some were similar to living crocodylians and were primarily carnivorous, others were omnivores and still others likely specialized in plants."

The researchers looked at 146 fossilised teeth from 16 different species. When matched to living reptiles, they found that the shape of the teeth gave them a pretty good guess if these ancient crocodilians preferred meat or something greener.

If you can imagine a carnivore, their teeth are usually sharp single points, with not a lot of complexities. But animals who eat plants have teeth with lots and bumps and grooves to really mash up the plants before swallowing.

Press Figure Melstrom 937x394(Keegan Melstrom)

"Omnivores, organisms that eat both plant and animal material, fall somewhere in between. Part of my earlier research showed that this pattern holds in living reptiles that have teeth, such as crocodylians and lizards," explains Melstrom.

"So, these results told us that the basic pattern between diet and teeth is found in both mammals and reptiles, despite very different tooth shapes, and is applicable to extinct reptiles."

The researchers found that the first plant-eating crocodyliforms thrived during the very start of the Jurassic, and across the Jurassic and Cretaceous periods, crocodyliforms exclusively eating plants evolved at least three times.

"Results suggest that herbivory independently evolved a minimum of three times, and possibly six times," explain the researchers.

"This study indicates that herbivorous crocodyliforms were more common than previously thought and were present throughout the Mesozoic and on most continents."

Crocodyliform life reconstructions Credit Jorge GonzalezReconstructions of crocodyliform. (Jorge Gonzalez)The team found eight herbivores – with flattish and gnarled teeth - and at least one omnivore in the 16 ancient species.

Other researchers are excited at the team's approach.

"This method can be replicated and expanded with the discovery of new fossils, which should allow us to test different ideas for why herbivory repeatedly evolved in crocs," Ohio University palaeontologist Patrick O'Connor told National Geographic.

The team aren't finished yet – they are currently reconstructing the diet of these crocodyliforms, and are hoping to investigate why these creatures became so diverse in the time of the dinosaurs, but not more recently.

"The herbivores lived on different continents at different times, some alongside mammals and mammal relatives, and others did not," adds Melstrom. "This suggests that an herbivorous crocodyliform was successful in a variety of environments!"

The research has been published in Cell Biology.