📍 Distance Calculator
Calculate distance between two points on Earth. Coordinates or cities — instant results in km, miles, and nautical miles.
Point A
Point B
📋 When to Use the Distance Calculator
Use the Distance Calculator to find the straight-line (great-circle) distance between any two points on Earth. Perfect for travel planning, logistics estimates, geography homework, flight distance calculations, and curiosity about how far apart two cities are. The Haversine formula provides accurate as-the-crow-flies distances accounting for Earth's curvature.
⚙️ How the Distance Calculator Works
The Distance Calculator processes your input using the Haversine formula — a mathematical equation that computes the great-circle distance between two points on a sphere given their latitudes and longitudes. All calculations run entirely in your browser using JavaScript — no data is sent to any server. Earth's radius is approximated at 6,371 km. Results are displayed in kilometers, miles, and nautical miles simultaneously. For cities, a built-in database of 400+ cities worldwide provides coordinates for instant lookup.
How to Use the Distance Calculator
- Select a mode — Choose Coordinates (enter lat/lon manually), Cities (search from 400+ cities), or Hybrid (mix of both).
- Enter the two points — Type latitude/longitude in decimal (e.g. 40.7128, -74.0060) or DMS format (e.g. 40°42′46″N, 74°0′22″W). For cities, start typing and select from the autocomplete list.
- Click Calculate — The distance appears instantly in kilometers, miles, and nautical miles.
- Switch modes anytime — Values carry over between modes for quick comparisons.
Frequently Asked Questions
What is the Haversine formula?
The Haversine formula calculates the great-circle distance between two points on a sphere. It accounts for Earth's curvature and is accurate to within 0.5% for most distances. It uses the central angle between the two points and multiplies by Earth's mean radius (6,371 km).
What's the difference between straight-line and driving distance?
This calculator shows straight-line (as-the-crow-flies) distance. Driving or walking distance is always longer because roads follow terrain and infrastructure. For driving distances, use a mapping service like Google Maps.
Can I enter DMS coordinates like 40°42′46″N?
Yes! The calculator accepts both decimal (40.7128) and DMS (degrees-minutes-seconds) formats with compass directions (N/S/E/W). Just type the DMS string and it will be parsed automatically.
How accurate are the distance calculations?
Very accurate for most practical purposes. The Haversine formula is accurate to within 0.5% for distances over 100 km. For very short distances (< 1 km), a simple Pythagorean approximation on a flat surface may differ slightly. Earth's ellipsoidal shape is not modeled — we use the mean radius of 6,371 km.
Does it work offline?
Yes! All calculation logic runs in JavaScript. Once loaded, the Distance Calculator works without internet — though the city database requires an initial fetch.