Photo Location & Postal Code Tools

Postal Code Distance Calculator

Measure great-circle distance between postal codes resolved offline: many pairs at once from pasted CSV, a full distance matrix for a list of codes, bearings, and kilometres or miles with the unmatched codes listed.

  • Distance and bearing per pair
  • Distance matrix
  • CSV and JSON export
Runs in your browser

Everything you paste, type or drop is processed in this browser tab. It is not uploaded, logged, stored or sent to analytics.

Code distance workspace

1 Country

2 Pairs or a matrix

What to calculate

Pairs: one pair per line, two codes separated by a comma, with an optional label as a third column. Up to 1,000 pairs.

Units
Try:
Which countries are covered, and what is missing

3 Distances

Paste pairs of postal codes, or a list for a full matrix. Each code is resolved offline, and any that cannot be resolved is listed rather than silently skipped.

How this differs from Distance Between Two Coordinates and Distance Between Two Airports

The existing distance tools measure between two coordinates or two airports, one pair at a time. This calculator works in postal codes, resolves them offline from the GeoNames dataset, accepts many pairs at once from pasted CSV, and can build a full distance matrix for a list of codes rather than a single answer.

What the Postal Code Distance Calculator does

Measure the straight-line distance between postal codes: paste a column of pairs and get a distance and bearing for each, or paste a list and get the full matrix of every code against every other. Each code is resolved to coordinates offline, from the GeoNames postal export vendored on this site, so nothing you paste is sent to a geocoder.

The distances are great-circle distances between the representative point of each code - as the crow flies, not as the road runs. That is the right measure for catchment areas, territory planning, nearest-branch questions and delivery-zone sanity checks; it is the wrong measure for an estimated drive time.

How to use it

  1. Choose the country. Postal codes are only unique within a country, so every code in one run must belong to the same one.
  2. Choose pairs or a matrix. Pairs takes one pair per line, two codes separated by a comma, with an optional third column used as the row label. Matrix takes a plain list of codes, up to sixty.
  3. Pick kilometres or miles, and tick the Vincenty option if you want the ellipsoidal distance alongside the spherical one.
  4. Press Calculate. The country file loads once and every run after that is instant.
  5. Read the unresolved table before trusting the totals - a pair with one unknown code produces no distance at all, and is listed rather than dropped.

Reading the results

A distance here is between two areas, not two addresses. Where both codes cover a city block the error is metres; where one covers a rural district it can be several kilometres, and for a UK outward code it is the centre of the whole outward area.

The bearing is the initial great-circle bearing from the first code to the second, named on the 16-point compass. Over long distances the bearing changes along the route, which is why it is labelled initial.

The Vincenty figure models the earth as an ellipsoid rather than a sphere and is the more accurate of the two, typically by two to four parts in a thousand. Where it reports that it did not converge - only on nearly antipodal pairs - no number is shown, because a wrong number would be worse.

A ≈ against a pair means at least one code matched only on its leading part, so the distance is between wider areas than the codes you typed.

Worked example: four Indian city pairs

Delhi 110001 to Mumbai 400001 comes out at 1,166.574 km - 724.876 miles - on an initial bearing of 203.5 degrees, which is south-south-west. With the Vincenty option on, the ellipsoidal figure is 1,162.942 km, about 0.3 per cent shorter, which is the usual size of the difference.

Mumbai 400001 to Chennai 600001 is 1,029.793 km on a bearing of 128.1 degrees, south-east; Bengaluru 560001 to Kolkata 700001 is 1,540.618 km, north-east.

Delhi to Bengaluru reads 1,714.047 km, which is around 25 km shorter than the figure you will see quoted for the two city centres. The reason is visible in the data: GeoNames records 560001 at 13.2257 N, some way north of the centre of Bengaluru. That is exactly the sort of thing a postal-code distance carries, and why it is a planning measure rather than a precise one.

Formulas and scoring rules

Great-circle distance (haversine)
d = 2R asin(sqrt(sin^2((lat2-lat1)/2) + cos(lat1) cos(lat2) sin^2((lon2-lon1)/2)))R = 6,371,008.8 m, the WGS 84 mean radius. Accurate to about 0.3 per cent against the ellipsoid.
Ellipsoidal distance (Vincenty inverse)
iterative solution on the WGS 84 ellipsoid a = 6,378,137 m, f = 1/298.257223563Reports non-convergence rather than a wrong figure for nearly antipodal points.
Initial bearing
theta = atan2(sin(dlon) cos(lat2), cos(lat1) sin(lat2) - sin(lat1) cos(lat2) cos(dlon))Normalised to 0-360 degrees from true north.
Miles
miles = km / 1.609344The international mile, exactly 1,609.344 m.
Matrix
cell[i][j] = distance(code i, code j), with cell[i][i] = 0Symmetric, so the two halves always agree. Capped at 60 codes, which is 3,600 cells.

How this differs from the existing distance tools

The Distance Between Two Latitude and Longitude tool measures between two coordinates you already have, and the Distance Between Two Airports tool measures between two airport codes - both one pair at a time. This calculator works in postal codes instead, resolves them offline from the vendored dataset, takes hundreds of pairs at once from pasted CSV, and can produce a full distance matrix for a list rather than a single answer. If you already have coordinates, use the coordinate tool; if you have a spreadsheet column of postcodes, use this one.

Limitations: what the result does not prove

  • Straight-line distance only. There is no road network here, so a figure will always be shorter than the drive, by anything from ten per cent on a motorway corridor to several times in mountains.
  • The precision is the precision of a postal code. Each code contributes one representative point, and a code covering a large area contributes a point that may be kilometres from the address you had in mind.
  • Both codes must be in the same country and in the covered list. A pair with one unresolved code produces no distance and is reported.
  • The matrix is capped at 60 codes, because the work grows with the square of the list and a browser tab should stay usable.

Privacy: where your data goes

Everything you paste, type or drop is processed in this browser tab. It is not uploaded, logged, stored or sent to analytics. Session recording and tag-manager scripts are switched off on this page.

Standards and sources

Frequently asked questions

Is this driving distance or straight-line distance?

Straight-line, along the great circle. There is no routing data involved, so it will always be shorter than the road distance. As a rough guide, road distance in a well-connected region runs twenty to thirty per cent longer, but the ratio varies enormously with geography.

How many pairs can I measure at once?

A thousand pairs per run, and up to sixty codes for a matrix. Every code is resolved once and reused, so a run with many repeated codes costs little more than a run with few.

Why does the distance between two city codes look slightly wrong?

Because a postal code is an area and the dataset stores one representative point for it, which is not always the city centre. Where a code covers a whole district, or where the dataset's point sits on the edge of a conurbation, the distance shifts by a few kilometres. The worked example on this page shows exactly that happening.

What is the difference between the haversine and Vincenty figures?

Haversine treats the earth as a sphere; Vincenty solves the same problem on the WGS 84 ellipsoid, which is flattened at the poles. The ellipsoidal answer is more accurate, usually by two to four parts in a thousand - a few kilometres over a thousand - and it is the one to quote when the number matters.

Can I mix postal codes from different countries?

Not in one run. Codes are only unique within a country and the lookup searches one country's file at a time, so a cross-border pair has to be resolved in two runs. Convert each side to coordinates with the Postal Code to Coordinates tool, then measure between the coordinates.

What happens to a code that is not in the dataset?

The pair is listed in the unresolved table with the reason, and no distance is produced for it. Nothing is estimated, substituted or quietly skipped, because a silently dropped row is how a total ends up wrong without anyone noticing.

Is this accurate enough for delivery zone planning?

For drawing catchments and deciding which depot serves which postal area, yes - the error from the code's own size is usually much smaller than the zone you are drawing. For quoting a customer a delivery charge based on distance, use road distance from a routing service instead.

Last reviewed by the A2Z.Tools team against the sources listed above.

Rate this tool

Was this tool useful? Your feedback helps us improve it.

No ratings yet — be the first to rate this tool.
Your rating (required)
0 / 2000

Please do not include passwords, payment details or other sensitive information.

Your feedback is sent privately to the A2Z.Tools team and will not be posted publicly.