The 20 most expensive ZIP codes

If you think it's expensive living in Silicon Valley or Beverly Hills, try buying a place in Sagaponack, New York.

The median sales price for a home in the tony Hamptons village is more than $5.1 million, making it the most expensive ZIP code in the U.S. when it comes to real estate, according to PropertyShark.

An outdoor party at a home in Sagaponack, New York.
Getty Images
An outdoor party at a home in Sagaponack, New York.

The analysis, which looked at median prices for homes that sold between January 2014 and May 2015, found the Eastern Long Island town was followed by Atherton, California, in Silicon Valley, and then Beverly Hills.

Read MoreThe problem with million-dollar Hamptons rentals

In total, California claimed four of the top five spots, and 14 of the top 20. New York claimed all the other top ZIP codes, with the exception of Miami Beach, Florida, which came in ninth.

The median sales prices for the top 20 ZIP codes were all higher than $2 million, with each of the top 10 coming in at or above $2.6 million—about 10 times the national average median home price, according to the U.S. Census Bureau.

See below for the full list.

Rank
Zip code
Media sales price
Number of sales
City
1 11962 $5,125,000 30 Sagaponack, NY
2 94027 $5,050,000 115 Atherton, CA
3 90210 $3,221,250 578 Beverly Hills, CA
4 90402 $3,062,250 206 Santa Monica, CA
5 94301 $2,827,500 245 Palo Alto, CA
6 10013 $2,800,000 431 New York, NY
7 10007 $2,763,711 126 New York, NY
8 92662 $2,675,000 28 Newport Beach, CA
9 33109 $2,650,000 57 Miami Beach, FL
10 94022 $2,600,000 392 Los Altos, CA
11 94028 $2,450,000 93 Portola Valley, CA
12 93108 $2,400,000 233 Santa Barbara, CA
13 10282 $2,400,000 30 New York, NY
14 92067 $2,350,000 211 Rancho Santa Fe, CA
15 92657 $2,349,500 274 Newport Coast, CA
16 11976 $2,337,500 146 Water Mill, NY
17 94024 $2,302,500 368 Los Altos, CA
18 92661 $2,300,000 92 Newport Beach, CA
19 90272 $2,240,000 621 Pacific Palisades, CA
20 91108 $2,134,000 228 San Marino, CA
PropertyShark
CNBC NEWSLETTERS

Get the best of CNBC in your inbox

Please choose a subscription

Please enter a valid email address
Get these newsletters delivered to your inbox, and more info about about our products and service. Privacy Policy.