The area was settled in the late 17th century as part of the Elizabethtown Tract.
Westfield was originally formed as a township on January 27, 1794, from portions of Elizabeth Township, while the area was still part of Essex County, and was incorporated as a one of New Jersey's first 104 townships by an Act of the New Jersey Legislature on February 21, 1798. It became part of the newly-formed Union County on March 19, 1857. Portions of the township have been taken to form Rahway Township , Plainfield Township , Cranford Township , Fanwood Township and Hillside . The Town of Westfield was incorporated on March 4, 1903, replacing Westfield Township. Barely two weeks later, the Borough of Garwood was created from portions of Westfield and Cranford Township, on March 19, 1903.
As of the census of 2000, there were 29,644 people, 10,622 households, and 8,178 families residing in the town. The population density was 4,403.1 people per square mile (1,700.7/km²). There were 10,819 housing units at an average density of 1,607.0/sq mi (620.7/km²). The racial makeup of the town was 89.98% White, 3.88% African American, 0.09% Native American, 4.08% Asian, 0.01% Pacific Islander, 0.62% from other races, and 1.33% from two or more races. Hispanic or Latino of any race were 2.82% of the population.
There were 10,622 households out of which 40.8% had children under the age of 18 living with them, 68.0% were married couples living together, 7.1% had a female householder with no husband present, and 23.0% were non-families. 19.3% of all households were made up of individuals and 9.4% had someone living alone who was 65 years of age or older. The average household size was 2.77 and the average family size was 3.20.
In the town the population was spread out with 28.4% under the age of 18, 4.0% from 18 to 24, 29.6% from 25 to 44, 24.5% from 45 to 64, and 13.5% who were 65 years of age or older. The median age was 39 years. For every 100 females there were 92.1 males. For every 100 females age 18 and over, there were 87.4 males.
According to a 2007 estimate, the median income for a household in the town was $120,978, and the median income for a family was $146,891. Males had a median income of $82,420 versus $45,305 for females. The per capita income for the town was $47,187. About 1.7% of families and 2.7% of the population were below the poverty line, including 3.3% of those under age 18 and 3.1% of those age 65 or over.