Modern crocodiles had ancient vegetarian cousins that roamed the planet 200 million years ago, research shows.
Tooth fossils revealed between three and six members of the crocodile and alligator family had specialized teeth for chewing on plants.
Researchers reconstructed their vegetarian diets by analyzing the fossils of 146 teeth from 16 crocodyliforms.
Many of their "complex" sets of teeth were shaped unlike any modern day herbivore until the plant-eaters were wiped out along with the dinosaurs 66 million years ago.
Study author Keegan Melstrom, a doctoral student at the University of Utah, US, said: "The most interesting thing we discovered was how frequently it seems extinct crocodyliforms ate plants.
"Carnivores possess simple teeth whereas herbivores have much more complex teeth.
"Omnivores, organisms that eat both plant and animal material, fall somewhere in between.
"Our study indicates that complexly-shaped teeth, which we infer to indicate herbivory, appear in the extinct relatives of crocodiles at least three times and maybe as many as six.
"Part of my earlier research showed that this pattern holds in living reptiles that have teeth, such as crocodylians and lizards.
"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."
All crocodylians alive today have a similar body shape with relatively simple, conical teeth ideal for their semi-aquatic generalist carnivore lifestyles.
But the tooth fossils in the study were clearly non-carnivorous and appeared to have specialized forms not seen in modern day animals.
Mr. Melstrom and Dr. Randall Irmis, chief curator of paleontology at the Natural History Museum of Utah, US, compared the tooth complexity of extinct crocodyliforms to those of living animals to work out what they ate.
They used a method that was originally developed for use in living mammals - measuring the teeth's dimensions and morphological features at a resolution of 25 data rows per tooth.
Mr. Melstrom said the unexpected variety in crocodyliforms' teeth showed they were able to thrive in a greater range of ecological environments than previously thought.
He also found the plant-eaters appeared early in the evolutionary history of the family, shortly after the end-Triassic mass extinction some 200 million years ago.
They existed until the end-Cretaceous mass extinction that killed off all dinosaurs except birds.
The fossil analysis suggested that between three and six species evolved herbivore diets during in Mesozoic era.
Mr. Melstrom said: "Our work demonstrates that extinct crocodyliforms had an incredibly varied diet.
"Some were similar to living crocodylians and were primarily carnivorous, others were omnivores and still others likely specialized in plants.
"The herbivores lived on different continents at different times, some alongside mammals and mammal relatives, and others did not.
"This suggests that an herbivorous crocodyliform was successful in a variety of environments."
He planned to continue to reconstruct the diets of extinct crocodyliforms, including in fossilized species that are missing teeth.
The researcher also wanted to understand why the extinct relatives of crocodiles diversified so radically after one mass extinction but not the one that killed the dinosaurs - and whether dietary ecology could have played a role.
The study by the University of Utah and the National History Museum of Utah in the US was published in the journal Current Biology.