(WHDH) — Five Massachusetts towns have been ranked among the safest small communities in America, according to a new study.

MoneyGeek recently released its ranking of the safest and most dangerous small cities and towns in the U.S. in 2020.

The personal finance technology company says it analyzed crime in 989 small cities and towns to find the cost of crime.

Franklin was named the safest small town, while Shrewsbury checked in as the second safest community. Needham wasn’t far behind, earning a 12th place ranking.

Andover and Billerica also landed inside the top 25 safest communities, placing 19th and 23rd, respectively.

Gary, Indiana, Pine Bluff, Arkansas, Petersburg, Virginia, Chester, Pennsylvania, and Camden, New Jersey, were ranked as the top five most dangerous places.

The study also revealed that many Americans fled large cities in the wake of the COVID-19 pandemic in search of “a sense of security in small-town America.”

Click here to view a full list of the safest and most dangerous cities and towns.

(Copyright (c) 2020 Sunbeam Television. All Rights Reserved. This material may not be published, broadcast, rewritten, or redistributed.)

Join our Newsletter for the latest news right to your inbox