Sanford is a city in York County, Maine, United States. The population was 21,982 in the 2020 census.