Home › Generators › Qibla Direction Finder

Qibla Direction Finder

Use this free qibla direction finder to find the exact direction of the Kaaba in Makkah from anywhere in the world. Type your latitude and longitude, or tap "Use my location" and let your device fill them in, and the tool instantly shows the qibla bearing in degrees from north, the compass direction, and the distance to the Kaaba in kilometers and miles. The compass rose updates live as you type, and everything runs in your browser — nothing you enter is stored or shared.

58.5° Northeast
From New York (40.7128° N, 74.0060° W) to the Kaaba in Makkah
MeasurementValue
Qibla bearing (from true north)58.5°
Compass directionNortheast
Distance to the Kaaba10,306 km
Distance in miles6,404 miles
Kaaba coordinates21.4225° N, 39.8262° E

Your qibla compass

N S E W NE SE SW NW 58.5° NE

The blue needle points toward the Kaaba. Face the bearing shown — for example, 58.5° means 58.5° clockwise from north — and you are facing the qibla.

How it works

The qibla is the direction of the Kaaba, the cube-shaped building at the center of the Grand Mosque in Makkah, Saudi Arabia, which stands at 21.4225° north and 39.8262° east. Muslims face the qibla when they pray, so knowing the direction matters wherever you are — at home, at work, or travelling. This finder works out that direction from your latitude and longitude using the same mathematics navigators have used for centuries: the shortest path over the surface of a sphere, called a great circle.

The bearing. The tool uses the standard initial-bearing formula from spherical trigonometry. It takes your position and the Kaaba's position and computes the angle of the great-circle path as it leaves your location, measured clockwise from true north. A bearing of 0° means due north, 90° means due east, 180° means due south, and 270° means due west. The result is also translated into a plain compass direction — North, Northeast, East, and so on — so you can read it at a glance.

The distance. The distance is worked out with the haversine formula, which measures the great-circle distance between two points on a sphere. It assumes the Earth is a sphere with a radius of 6,371 kilometers, which is accurate to well within a fraction of a percent for this purpose. The distance is shown in kilometers and in miles.

Bearing = atan2( sin(Δλ) · cos(φ₂), cos(φ₁) · sin(φ₂) − sin(φ₁) · cos(φ₂) · cos(Δλ) )   |   Kaaba: 21.4225° N, 39.8262° E

In that formula, φ₁ is your latitude, φ₂ is the Kaaba's latitude, and Δλ is the difference in longitude. The result is converted from radians to degrees and adjusted to a value between 0° and 360°.

Finding your coordinates. If you know your latitude and longitude, just type them in — the bearing, direction, and distance update as you type, and the compass needle swings to match. If you don't know them, click "Use my location" and your browser will ask permission to use your device's GPS. If you decline, or if location is unavailable, nothing breaks: the tool keeps the coordinates you already have and shows a short message explaining what happened. You can also look up your coordinates in any maps app by long-pressing your location and copying the numbers it shows.

Using the bearing in practice. The bearing is measured from true north, not magnetic north. Most phone compasses show magnetic north, which can differ from true north by several degrees depending on where you are — a difference called magnetic declination. For everyday prayer, the difference is small, but if you want the most accurate result, use a compass app that shows true north, or look up the magnetic declination for your city and adjust. Stand away from metal objects, cars, and electronics, which can pull a phone compass off by several degrees, and calibrate the compass by moving your phone in a figure-eight motion first.

Worked example

Let's work through the default example on this page: New York, at 40.7128° north and 74.0060° west.

First, the tool takes New York's coordinates and the Kaaba's coordinates (21.4225° N, 39.8262° E) and applies the initial-bearing formula. The difference in longitude is 39.8262 − (−74.0060) = 113.8322°. Plugging the numbers into the formula gives a bearing of 58.5° measured clockwise from true north. A bearing between 22.5° and 67.5° is the northeast quarter, so the compass direction is Northeast.

Next, the distance. The haversine formula gives a great-circle distance of 10,306 km from New York to the Kaaba, which is 6,404 miles. Type 40.7128 and −74.0060 into the finder above and you will get exactly 58.5° Northeast, 10,306 km, and 6,404 miles, with the compass needle pointing northeast.

For comparison, from London (51.5074° N, 0.1278° W) the bearing is about 119.0° — southeast — and the distance is about 4,794 km. From Karachi (24.8607° N, 67.0011° E) the bearing is about 267.7° — almost due west — and the distance is about 2,800 km. The same formula gives the right answer in every case, in both hemispheres.

FAQ

What is the qibla?

The qibla is the direction Muslims face when they pray. It points toward the Kaaba, the cube-shaped building at the center of the Grand Mosque in Makkah, Saudi Arabia. The Kaaba stands at about 21.4225 degrees north and 39.8262 degrees east. Wherever you are in the world, the qibla is the shortest direction — the great-circle direction — from your location to the Kaaba.

How is the qibla direction calculated?

The tool uses the standard initial-bearing formula from spherical trigonometry. It takes your latitude and longitude and the Kaaba's coordinates (21.4225° N, 39.8262° E) and works out the angle, measured clockwise from true north, of the shortest path over the surface of the Earth to the Kaaba. The distance is worked out with the haversine formula, which measures the great-circle distance between the two points. The worked example on this page shows the full calculation for New York.

Do I need to allow location access?

No. The qibla finder works fully without location access: just type your latitude and longitude into the two boxes and the bearing and distance appear instantly. If you prefer, you can click the Use my location button, which asks your browser for your position using GPS. If you decline, or if location is unavailable, the tool simply keeps using the coordinates you typed in.

How accurate is the qibla direction?

The bearing calculation itself is exact for a spherical Earth, accurate to a small fraction of a degree. In practice, the result is only as good as the coordinates you enter and the compass you use to face the direction. A phone compass can be off by several degrees near metal objects or electronics, so stand away from them and calibrate your compass by moving your phone in a figure-eight motion before relying on it.

What if I am in the southern hemisphere?

The qibla finder works the same way everywhere on Earth, including the southern hemisphere. The bearing formula uses your latitude and longitude wherever you are, so the direction it gives is always correct for your location. What changes is the direction itself: from most of the southern hemisphere the qibla points northwest, north, or northeast rather than east or southeast, and the compass rose on this page always shows the correct direction for the coordinates you entered.

Related tools