quality:correction, structural:scholar_edition, linguistic:voice_change
Demographics

As of 2023, Shanghai had a total population of 24,874,500, including 14,801,700 (59.5%) hukou holders (registered locally). As of 2022, 89.3% of Shanghai's population live in urban areas, and 10.7% live in rural areas. Based on the population of its total administrative area, Shanghai is the second largest of the four municipalities of China, behind Chongqing, but is generally considered the largest Chinese city because the urban population of Chongqing is much smaller. According to the OECD, Shanghai's metropolitan area has an estimated population of 34 million.

According to the Shanghai Municipal Statistics Bureau, about 157,900 residents in Shanghai are foreigners, including 28,900 Japanese, 21,900 Americans and 20,800 Koreans. The actual number of foreign citizens in the city is probably much higher. Shanghai is also a domestic immigration city—40.3% (9.8 million) of the city's residents are from other regions of China.

Shanghai has a life expectancy of 83.18 years for the city's registered population, the highest life expectancy of all cities in mainland China. This has also caused the city to experience population aging —in 2021, 17.4% (4.3 million) of the city's registered population was aged 65 or above. In 2017, the Chinese government implemented population controls for Shanghai, resulting in a population decline of 10,000 people by the end of the year.