What the Qibla Actually Is
The Qibla is the direction of the Kaaba in Makkah — the black cube at 21.4225° N, 39.8262° E. For anyone standing anywhere on Earth, it is simply the compass heading you would follow if you walked in a perfectly straight line (a great circle) and arrived at the Kaaba.
Because Earth is a sphere, that heading is not the same as drawing a line on a flat map and measuring its angle. Flat-map bearings drift; great-circle bearings do not. This tool always computes the great-circle version, which is what scholars and navigators mean by the Qibla.
The Formula
With φ as your latitude, λ as your longitude, and φQ / λQ as the Kaaba’s coordinates:
Δλ = λQ − λ
θ = atan2(
sin(Δλ) · cos(φQ),
cos(φ) · sin(φQ) − sin(φ) · cos(φQ) · cos(Δλ)
)
qibla = (θ mod 360°)The result is measured clockwise from true north: 0° is North, 90° is East, 180° is South. Distance uses the haversine formula on a 6,371 km sphere — accurate to within about half a percent of the ellipsoid value.
Worked Examples
The exact numbers this site produces for six cities:
| City | Coordinates | Qibla | Distance |
|---|---|---|---|
| London, UK | 51.5074°, -0.1278° | 119.0° | 4,794 km |
| New York, USA | 40.7128°, -74.0060° | 58.5° | 10,306 km |
| Istanbul, Türkiye | 41.0138°, 28.9497° | 151.6° | 2,407 km |
| Jakarta, Indonesia | -6.2088°, 106.8456° | 295.2° | 7,920 km |
| Cairo, Egypt | 30.0444°, 31.2357° | 136.1° | 1,287 km |
| Sydney, Australia | -33.8688°, 151.2093° | 277.5° | 13,236 km |
Try your own city with the live tool on thehome page.
True North vs. Magnetic North
The formula returns a true-north bearing. Your phone’s magnetometer senses magnetic north, which differs by the local magnetic declination — usually a few degrees, occasionally more. Newer phones (and iPhones with location access enabled) report a heading already corrected to true north; many Android devices report magnetic heading.
- If the reading sits within a few degrees of where other reliable tools point, you are fine — that is normal declination.
- If it is wildly off, the sensor is confused: calibrate with the figure-8 guide and remove magnetic cases, pop-sockets or car mounts.
- Stand still while reading. Rotating the phone quickly smears the magnetometer output.
Why You Can Trust the Number
There is no server involved. The bearing is computed in your browser from your coordinates and the Kaaba’s fixed coordinates — you can verify it yourself with the formula above, on paper, and get the same tenth of a degree. The only uncertainty in the whole system is your device’s compass hardware.
Read about how little data we keep in theprivacy policy, or jump totroubleshooting if a reading looks wrong.