Ibn ʿUmar (may Allah be pleased with them) instructed a man, “When you lie down to sleep, say: ‘Allāhumma anta khalaqta nafsī wa anta tatawaffāhā, laka mamātuhā wa maḥyāhā. In aḥyaitahā faḥfaẓhā, wa in amattahā faghfir lahā. Allāhumma innī asʾaluka al-ʿāfiyah (O Allah, You created my soul and You will take it; to You belong its death and its life. If You keep it alive, protect it, and if You cause it to die, forgive it. O Allah, I ask You for well-being).’” Ibn ʿUmar added, “I heard this from the Messenger of Allah, peace and blessings be upon him.” Recorded by Muslim.
Abu Saʿīd al-Khudrī (may Allah be pleased with him) reported that the Messenger of Allah, peace and blessings be upon him, said: “Whoever, upon retiring to his bed, says: Astaghfiru-llāha al-ʿaẓīm alladhī lā ilāha illā Huwa al-Ḥayyul-Qayyūm wa atūbu ilayh (I seek the forgiveness of Allah the Magnificent—there is no god but Him—the Ever-Living, the Sustainer, and I repent to Him) three times, Allah will forgive his sins even if they were like the foam of the sea, the grains of the desert sand, or the number of the days of the world.” Al-Tirmidhī said, “A ḥasan gharīb (sound and singular) narration.
Abu Hurayrah (may Allah be pleased with him) narrated that when the Prophet, peace and blessings be upon him, lay down to sleep he would say: “Allāhumma Rabb as-samāwāt, Rabb al-arḍ, Rabb al-ʿarsh al-ʿaẓīm, Rabbanā wa Rabba kull shayʾ, Fāliq al-ḥabbi wan-nawā, Munzila at-Tawrāt wal-Injīl wal-Furqān, aʿūdhu bika min sharri kulli dhī sharr anta ākhidhun binaṣiyatih. Allāhumma anta … (O Allah, Lord of the heavens, Lord of the earth, Lord of the Mighty Throne, our Lord and the Lord of everything, Splitter of the grain and the date-stone, Revealer of the Torah, the Gospel, and the Furqān, I seek refuge in You from the evil of every creature whose forelock You hold. O Allah, You are…)."