Many definitions of "within X miles" exist. For instance, must the entirety of the ZIP be within the radius or only a part? Should measurements be taken from the center of a ZIP or from the edge? Because no clear answer exists and different people will want to use different definitions, the tool above displays both the radius from the chosen point and which ZIP codes are selected. In this way, you can click each ZIP on the map to add/remove it from your selection and choose the definition that works best for your use case.
The tool above measures the distance between two points to determine whether a ZIP is within the radius of a location. First, if a ZIP code or city is entered as the primary location, a central point is chosen as if an address were entered. Next, ZIP codes within the radius are chosen based on coordinates for ZIP codes. As mentioned in that article, many ways exist to simplify the complex shapes of ZIP codes down to a single point, but this tool uses "internal point coordinates" discussed in that article. If the central point of the ZIP code is within the radius of the primary location, the ZIP code is considered to be within the radius.
The Haversine formula/spherical law of cosines can be used to determine the distance between two points on a sphere like the Earth. To use it, you'll need the latitude and longitude coordinates of two points. For ZIP codes, you can download a list of ZIP codes for Excel. For the starting coordinate, you can either choose the center point of another ZIP or lookup the coordinates for a primary point using our search or Google/Bing/Apple Maps.
The constant 3959 is the radius of the earth in miles. If you would rather have your result in kilometers, use 6371 (the radius of the earth in kilometers) instead. While the above treats the Earth as a sphere, the error introduced is very small and well under 1%. The formula can also be adapted to many other programming languages.