Shafter is a city in Kern County, California, United States. It is located 18 miles (29 km) west-northwest of Bakersfield. The population was 16,988 at the 2010 census, up from 12,736 at the 2000 census. The city is located along State Route 43.