DANBURY - What do New York City, San Francisco and southwestern Connecticut have in common?

They share some of the highest scores in the country for diversity - not only in ethnic terms but also in categories such as social class and household makeup - according to an analysis of 313 cities by a financial data website.

“The fact that we are ranked with such interesting cities as San Francisco is terrific for Danbury,” said long-term Mayor Mark Boughton, reacting to the analysis posted Thursday, May 12, 2016, by WalletHub. “It means people of all kinds want to live in Danbury.”

The analysis ranked Danbury 21st in the nation after weighing four categories of diversity. Stamford and Norwalk joined Danbury in the top 30, ranking 24th and 28th, respectively.

Among small cities with fewer than 100,000 residents, Danbury was the ninth most diverse city in the country.

In making its case for the “most kaleidoscopic places in America” WalletHub analysts said demographic diversification was important for the future of the country.

“As a result of the fresh perspectives, skills and technologies brought in by newcomers, the U.S. has developed a strong adaptability to change,” WalletHub’s analysis reads. “Conversely, those relying on old ways and specialized industries tend to be more susceptible to the negative effects of market volatility.”