53033 FipsDecoder
Independent city — not a county. Middlesex County has its own 5-digit FIPS code and appears as a county equivalent in federal datasets. It is administratively separate from any surrounding county.
25017 County FIPS Code

Middlesex County

Massachusetts · County seat: Cambridge · Independent city (not a county)

View on CensusDepth ↗

FIPS code 25017 is Middlesex County, Massachusetts. With a population of 1,623,109 (2022 ACS estimate), it ranks #1 in Massachusetts and #22 nationally. Middlesex County is part of the Boston-Cambridge-Newton, MA-NH. The state FIPS code for Massachusetts is 25. This code is used in Census Bureau, BLS, EPA, HUD, and USDA federal datasets to identify this county.

County FIPS

25017

State FIPS

25

MA

Population

1,623,109

2022 ACS · #22 nationally

Density

1,984.7/mi²

people per sq mile

Land Area

818

sq miles

Urban/Rural

Metro — 1M+ population

RUCC 1

How This FIPS Code Works

25 017
25 = State FIPS (Massachusetts)
017 = County FIPS

The 5-digit FIPS code 25017 is formed by combining the 2-digit state identifier 25 (Massachusetts) with the 3-digit county identifier 017. Together they uniquely identify Middlesex County in every US federal dataset. No two counties share the same 5-digit FIPS code.

Census ACS Data for FIPS 25017

From the 2022 ACS 5-year estimates — the same values you'd retrieve by querying the Census API with county FIPS 25017.

Median Household Income

$121,304

ACS B19013_001E

Poverty Rate

7.4%

ACS B17001 (below poverty level)

Median Age

38.8

ACS B01002_001E

Metropolitan Area

Adjacent Counties (5)

Counties that share a border with Middlesex County. Useful for regional analysis — these are the geographies you'd typically include when studying labor markets, commuting zones, or environmental spillovers around FIPS 25017.

Federal Datasets Using Code 25017

FIPS code 25017 appears as the county identifier in the following federal datasets. Analysts joining data across these sources use this code as the common geographic key.

Using FIPS Code 25017 in Code

Common patterns for querying federal datasets by this county's FIPS code. The leading zeros are significant — always treat FIPS codes as strings, not integers.

Census ACS API — Python 25017
import requests

url = "https://api.census.gov/data/2022/acs/acs5"
params = {
    "get":  "NAME,B19013_001E,B01003_001E",
    "for":  "county:017",
    "in":   "state:25",
    "key":  "YOUR_CENSUS_API_KEY",
}
r = requests.get(url, params=params)
data = r.json()  # [[header...], [Middlesex County, Massachusetts, income, pop, ...]
SQL — filtering by county FIPS 25017
-- 5-digit combined FIPS (state + county)
SELECT * FROM your_table WHERE county_fips = '25017';

-- Some datasets store state and county separately
SELECT * FROM your_table
WHERE state_fips = '25'
  AND county_fips = '017';

-- ⚠ Never cast to integer — leading zeros are lost:
-- county_fips = 25017 is WRONG for this county
R — tidycensus 25017
library(tidycensus)

get_acs(
  geography = "county",
  variables = c(income = "B19013_001E", pop = "B01003_001E"),
  state     = "25",
  county    = "017",
  year      = 2022
)
Zero-padding reminder: FIPS codes must always be stored and compared as zero-padded strings. 25 (not 25) and 017 (not 17) — losing the leading zeros is one of the most common data-join bugs in federal datasets. Full guide →

ZIP Codes in Middlesex County

ZIP codes do not align perfectly with county boundaries — a single ZIP code can span multiple counties, and a county can contain parts of many ZIP codes. The ratios below (from the Census 2020 ZCTA relationship file) show the land area share of each ZCTA that falls within Middlesex County. Why FIPS ≠ ZIP →

ZIP Code % in county
02493 100.0%
01432 100.0%
02472 100.0%
02474 100.0%
02476 100.0%
02478 100.0%
01431 100.0%
01450 100.0%
01460 100.0%
01463 100.0%
01464 100.0%
01469 100.0%
01474 100.0%
01701 100.0%
01702 100.0%
01718 100.0%
01719 100.0%
01720 100.0%
01721 100.0%
01730 100.0%
01731 100.0%
01741 100.0%
01742 100.0%
01746 100.0%
01748 100.0%
01749 100.0%
01752 100.0%
01754 100.0%
01760 100.0%
01770 100.0%

Showing top 30 of 83 ZIP codes by residential address share.

Other Counties in Massachusetts