As of the census of 2000, there were 27,149 people, 10,254 households, and 7,270 families residing in the town. The population density was 1,692.6 people per square mile (653.5/km²). There were 10,488 housing units at an average density of 653.9/sq mi (252.5/km²). The racial makeup of the town was 88.46% White, 5.70% African American, 0.10% Native American, 2.14% Asian, 0.05% Pacific Islander, 1.27% from other races, and 2.28% from two or more races. Hispanic or Latino of any race were 1.54% of the population.
There were 10,254 households out of which 30.3% had children under the age of 18 living with them, 55.8% were married couples living together, 11.6% had a female householder with no husband present, and 29.1% were non-families. 24.4% of all households were made up of individuals and 9.9% had someone living alone who was 65 years of age or older. The average household size was 2.60 and the average family size was 3.13.
In the town the population was spread out with 22.4% under the age of 18, 6.8% from 18 to 24, 30.4% from 25 to 44, 25.2% from 45 to 64, and 15.1% who were 65 years of age or older. The median age was 39 years. For every 100 females there were 92.2 males. For every 100 females age 18 and over, there were 87.5 males.
The median income for a household in the town was $57,838, and the median income for a family was $69,942. Males had a median income of $44,853 versus $31,971 for females. The per capita income for the town was $25,480. About 3.1% of families and 4.6% of the population were below the poverty line, including 4.8% of those under age 18 and 5.8% of those age 65 or over.
Stoughton is on an MBTA commuter rail line that runs to South Station in Boston via the Providence/Stoughton Line, giving residents easy access to employment opportunities in Boston's medical, educational, and financial districts. The Brockton Area Transit Authority (BAT) provides local bus service.