The best time
Tahajjud can be prayed any time after Isha until Fajr, ideally after some sleep. The best time is the last third of the night: the Prophet ﷺ said that Allah descends to the lowest heaven then and says: “Who is calling on Me, that I may answer him? Who is asking of Me, that I may give him? Who is seeking My forgiveness, that I may forgive him?” (Sahih al-Bukhari 1145). The tahajjud time tool calculates the last third for your city.
How many rakats
There is no fixed number. The minimum is two rakats; many pray eight. ʿAishah said the Prophet ﷺ did not pray more than eleven rakats at night, in Ramadan or outside it (Sahih al-Bukhari 1147): usually eight of tahajjud and three of witr. Quality matters more than quantity: “The deeds most loved by Allah are the regular ones, even if few” (Sahih al-Bukhari 6464).
How to pray it
Make wudu and pray in sets of two rakats, each ending with the salam: “The night prayer is two by two” (Sahih al-Bukhari 990). The Prophet ﷺ would begin with two short rakats. Recite whatever you know; longer recitation, long ruku and long prostrations are the Sunnah. Recite aloud or quietly, as suits the people around you. The rakats are prayed like any two-rakat prayer.
Ending with witr
“Make witr the last of your prayer at night” (Sahih al-Bukhari 998). If you are confident of waking, delay witr until after tahajjud; if not, pray it after Isha before sleeping, and then pray tahajjud in twos without repeating witr. In the Hanafi school witr is three rakats with Dua Qunoot, and after it say subḥāna-l-maliki-l-quddūs.
Duas of the night
When the Prophet ﷺ rose for tahajjud he would say a long dua beginning اللّٰهُمَّ لَكَ الْحَمْدُ، أَنْتَ قَيِّمُ السَّمَاوَاتِ وَالْأَرْضِ وَمَنْ فِيهِنَّ: “O Allah, to You belongs all praise; You are the Sustainer of the heavens and the earth and all in them…” (Sahih al-Bukhari 1120). Then ask for whatever you need, in any language, especially in prostration. On waking, say the dua when waking up.
Tips to wake up
Sleep early, after Isha, and make the intention to wake: if you sleep intending tahajjud and miss it, you are still rewarded for the intention. Set an alarm 20 minutes before Fajr to start small. Sleep on your right side after the duas before sleeping. Avoid heavy food late at night. Wake your spouse: the Prophet ﷺ praised a man who wakes his wife for prayer and a woman who wakes her husband (Sunan Abi Dawud 1308).
If you miss it
If sleep or illness stops you, the Prophet ﷺ would pray twelve rakats during the day instead (Sahih Muslim 746), meaning in the forenoon (ḍuḥā). Do not give up after a missed night; begin again the next night with two rakats.