Qibla Direction Calculator: Bearing and Distance to the Kaaba

Choose a city or enter your latitude and longitude to get the Qibla bearing in degrees from north and the distance to the Kaaba.

Runs in your browser. Your files never leave your device. See how to check

…

How to do it

  1. 1
    Choose the place

    Select a city or custom.

  2. 2
    Enter the coordinates

    For custom, type latitude and longitude.

  3. 3
    Read the bearing

    See the angle from true north.

  4. 4
    See the direction

    Read the compass direction and distance.

  5. 5
    Set the direction

    Use it with a compass or a map.

About this tool

The Qibla is the direction that Muslims face when they pray, towards the Kaaba in Makkah. The shortest path on the Earth's surface is a great circle, and the direction at the start of that path is the Qibla bearing. This calculator takes your latitude and longitude, or one of the preset cities of Bangladesh and Pakistan, and gives the bearing in degrees from true north, the nearest compass direction and the distance to the Kaaba. The bearing is measured from true north, so a compass needs a correction for magnetic declination.

Who this is for

Muslims who want to set the direction of prayer in a new home, mosque, office or hotel, students who study geography or astronomy, and developers who check their own Qibla code.

How the direction is found

The method uses spherical trigonometry. The Kaaba is at about 21.4225 degrees north and 39.8262 degrees east. For a place at latitude φ1 and longitude λ1, the initial bearing θ to the Kaaba is found with atan2 of sin(Δλ) cos φ2 and cos φ1 sin φ2 − sin φ1 cos φ2 cos(Δλ), where Δλ is the difference in longitude. The result is converted to a bearing from 0 to 360 degrees clockwise from true north. The distance is found with the haversine formula and an Earth radius of about 6,371 km.

Examples

From Dhaka the Qibla is about 277 degrees, a little north of due west, and the distance is about 5,170 km. From Karachi it is about 262 degrees, a little south of west, and from Lahore about 266 degrees. From London it is about 119 degrees, south-east, and from New York about 58 degrees, north-east. These bearings differ from a straight line on a flat map because the Earth is round.

Using a compass

A magnetic compass points to magnetic north, which differs from true north by the declination at your place. In Bangladesh the declination is small, about 0 to 1 degrees east, but in other places it can be several degrees. A phone compass also needs calibration and is affected by metal. For a precise result, use the bearing with a map or a sun-based check, for example at noon sun when it is over the Kaaba on certain days of the year.

The preset cities

The table lists Dhaka, Chattogram, Sylhet, Khulna, Rajshahi, Karachi, Lahore, Islamabad, Peshawar and Quetta with their latitude and longitude. You can change the values, add your own place by choosing custom, or look up your coordinates on a map. The result updates at once.

How to use it

Select a city or choose custom and type your latitude (north is positive) and longitude (east is positive). Read the bearing, the compass direction, the distance and the opposite bearing. The numbers can be used with a compass, a map or a drawing of a room.

Limits

This is a calculation. For a mosque, ask local scholars about the accepted direction, because some communities follow a traditional direction. The tool does not give prayer times.

Worked example

From Dhaka the Qibla bearing is about 277 degrees from true north, a little north of west, and the distance to the Kaaba is about 5,170 km.

Quick facts

Frequently asked questions

What does the bearing mean?

The angle clockwise from true north to the Qibla direction.

Is it the same as a compass reading?

No. A compass shows magnetic north. Correct for declination.

Can I use my own location?

Yes. Choose custom and type your latitude and longitude.

Does it give prayer times?

No. It gives the direction and distance only.

Why not a straight line on the map?

The shortest path on a round Earth is a great circle.

Is my data stored?

No. It stays in your browser.

Guides for this tool

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages