Qibla Direction Calculator
Calculate the exact Qibla direction (compass bearing) and distance to the Kaaba in Mecca from any location worldwide.
Qibla Direction Calculator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser — no data is sent to any server.
Formula: Qibla Bearing = atan2(sin(ΔLng) × cos(lat_K), cos(lat) × sin(lat_K) − sin(lat) × cos(lat_K) × cos(ΔLng))
Worked example — Qibla: ~243.6° (WSW) | Distance: ~3,420 km
Formula
Qibla Bearing = atan2(sin(ΔLng) × cos(lat_K), cos(lat) × sin(lat_K) − sin(lat) × cos(lat_K) × cos(ΔLng))
The Qibla direction is calculated using the great circle bearing formula. It computes the initial bearing along the shortest path on Earth's surface from your location to the Kaaba (21.4225°N, 39.8262°E). The result is a compass bearing in degrees measured clockwise from true north. Distance is calculated using the Haversine formula.
Worked Examples
Example 1: Qibla from Kabul, Afghanistan
Problem:Find the Qibla direction from Kabul (34.5553°N, 69.2075°E) to the Kaaba in Mecca.
Solution:dLng = 39.8262° - 69.2075° = -29.3813° y = sin(-29.3813°) × cos(21.4225°) = -0.4570 x = cos(34.5553°) × sin(21.4225°) - sin(34.5553°) × cos(21.4225°) × cos(-29.3813°) = -0.2270 bearing = atan2(-0.4570, -0.2270) ≈ 243.6° (WSW) Distance ≈ 3,420 km
Result:Qibla: ~243.6° (WSW) | Distance: ~3,420 km
Example 2: Qibla from New York, USA
Problem:Find the Qibla direction from New York (40.7128°N, 74.0060°W).
Solution:Using great circle formula with Kaaba at 21.4225°N, 39.8262°E The great circle path goes northeast across the Atlantic bearing ≈ 58.5° (ENE) Distance ≈ 10,870 km
Result:Qibla: ~58.5° (ENE) | Distance: ~10,870 km
Frequently Asked Questions
What is the Qibla and why is it important in Islam?
The Qibla is the direction that Muslims face during their daily prayers (Salah), pointing toward the Kaaba in Masjid al-Haram in Mecca, Saudi Arabia. It was established by divine command in the Quran (Surah Al-Baqarah, 2:144) when the direction of prayer was changed from Jerusalem to Mecca. Facing the Qibla is a mandatory requirement for the validity of prayer in Islam, and it symbolizes the unity of the Muslim Ummah worldwide as all Muslims face the same point during worship. The Qibla direction varies depending on the observer's geographic location and is calculated using spherical trigonometry to find the shortest arc on Earth's surface toward the Kaaba.
How is the Qibla direction calculated mathematically?
The Qibla direction is calculated using the great circle bearing formula from spherical trigonometry. Given the observer's latitude and longitude and the Kaaba's coordinates (21.4225°N, 39.8262°E), the formula computes the initial bearing of the shortest path on the Earth's surface between the two points. The key equation is: bearing = atan2(sin(dLng) × cos(lat2), cos(lat1) × sin(lat2) − sin(lat1) × cos(lat2) × cos(dLng)), where dLng is the difference in longitude. This gives the compass bearing in degrees from true north, measured clockwise. The result is the direction one should face for prayer.
What is the difference between Qibla direction and magnetic north?
The Qibla bearing calculated by this tool is relative to true north (geographic north pole), not magnetic north. Magnetic north differs from true north due to the Earth's magnetic field not being perfectly aligned with its rotational axis. This difference is called magnetic declination and varies by location and changes over time. If you are using a magnetic compass to find the Qibla, you must adjust for your local magnetic declination. For example, in New York the magnetic declination is approximately 13 degrees west, meaning you would need to subtract 13 degrees from the calculated Qibla bearing when using a compass. Many smartphone compass apps automatically compensate for this.
Does the Qibla follow the great circle or a straight line on a map?
The Qibla follows the great circle route, which is the shortest path between two points on Earth's curved surface. On a flat map (particularly the common Mercator projection), this path appears as a curved line, which can be counterintuitive. For example, from North America, the Qibla direction is roughly northeast rather than east or southeast as one might expect by looking at a flat map. This has been a topic of scholarly discussion in modern times. The majority of Islamic scholars agree that the great circle (shortest distance) method is correct, as it represents the true closest direction to the Kaaba on Earth's surface rather than a rhumb line on a flat projection.
What should I do if I cannot determine the exact Qibla direction?
Islamic jurisprudence provides accommodations for situations where the exact Qibla direction cannot be determined. If you are in an unfamiliar location without access to a compass or calculator, you should make your best effort (ijtihad) to determine the direction. You can ask local Muslims, look for the direction of a nearby mosque's mihrab, observe the sun's position, or use any available means. If you have exhausted all reasonable options and still cannot determine the Qibla, scholars agree that prayer in any direction is accepted, as Allah says in the Quran: 'To Allah belongs the east and the west. Wherever you turn, there is the face of Allah' (2:115). It is recommended to repeat the prayer if you later discover the correct direction.
How much does an error in my own coordinates move the computed bearing?
Very little, because the bearing depends on the angle your position subtends at the Kaaba. A positional error of one kilometre on a route of five thousand shifts the great-circle bearing by only about one hundredth of a degree, and even a ten-kilometre error stays near a tenth. Rounding your latitude and longitude to three decimal places is therefore harmless. Magnetic declination and compass wobble introduce errors of whole degrees, so they dominate the total uncertainty, not your coordinates.
How is the distance to the Kaaba computed and how exact is it?
The distance uses the Haversine formula, which measures the great-circle arc between two points on a sphere and multiplies it by a mean Earth radius of 6,371 kilometres. Because the Earth is an oblate spheroid rather than a true sphere, this spherical approximation typically differs from an ellipsoidal calculation by up to a few tenths of a percent, which works out to roughly ten kilometres on a three-thousand-kilometre route and around thirty on a ten-thousand-kilometre one. That is immaterial for orientation, since the bearing itself is far less sensitive to the shape assumption than the distance is.
How precisely do I need to face the Qibla for the prayer to be valid?
Classical jurists distinguish ayn al-Qibla, facing the exact point of the Kaaba, from jihat al-Qibla, facing its general direction. Those inside Masjid al-Haram or in visual range must face the structure itself. For everyone at a distance, the majority position is that the general direction suffices, because the Kaaba subtends an extremely small angle from far away and exactness would be impossible. A deviation of a few degrees does not invalidate the prayer; a deliberate turn toward a plainly wrong quarter of the horizon does.
Should I trust my phone's compass or the local mosque's mihrab?
The mihrab is generally the safer reference. It usually reflects a surveyed direction agreed by the local community, whereas a phone magnetometer is easily thrown off by steel framing, reinforced concrete, speakers, vehicles and even a magnetic phone case, and needs recalibration by figure-eight motion. If mihrab and phone disagree by more than a few degrees, check whether your compass app is reporting magnetic rather than true bearing, since the calculated figure here is measured from true north.
Can I verify the Qibla using the sun instead of a compass?
Yes. Twice a year the sun passes directly over the latitude of Mecca at the moment of its local solar noon, so anywhere on the daylit side of the Earth a vertical object's shadow points exactly away from the Kaaba and the Qibla lies straight along the shadow toward the sun. Outside those dates you can still cross-check by comparing the sun's known azimuth at a given clock time with your calculated bearing. This method needs no magnetic reading at all, which makes it useful indoors near steelwork or where declination data is unavailable.
References
Reviewed for accuracy by Daniel Agrici, Founder & Lead Developer · Editorial policy
Related Calculators
🧮Islamic Mortgage Calculator — Murabaha & Ijara
Calculate islamic mortgage with inputs, formulas, and instant results.
🧮Islamic Inheritance Calculator
Calculate islamic inheritance with inputs, formulas, and instant results.
🧮Islamic Date Calculator
Calculate days between two Hijri dates or convert Hijri date ranges to Gregorian.
🧮Islamic Will Calculator
Calculate Islamic inheritance shares (faraid) for all heirs according to Quran and Sunnah.
🧮Islamic Months Calculator
Convert between Hijri month names, numbers, and corresponding Gregorian date ranges.
🧮Zakat Calculator
Calculate zakat with inputs, formulas, and instant results.
🧮Zakat Al Fitr Calculator
Calculate zakat al fitr with inputs, formulas, and instant results.
🧮Profit Sharing Calculator
Calculate profit sharing with inputs, formulas, and instant results.