Sahih Muslim , Book 35, Hadith 6554 (USC-MSA)

Abu Huraira reported Allah's Messenger as say- ing: When any one of you goes to bed, he should take hold of the hem of his lower garment and then should clean (his bed) with the help of that and then should recite the name of Allah for he himself does tiot know what he left behind him on his bed, and when he intends to lie on bed, he should lie on his right side and utter these words:" Hallowed be Allah, my Lord. It is with Thine (grace) that I place my side (upon the bed) and it is with Thee that I take it up (after sleep), and in case Thou withholdst my being (if thou causest me to die), then grant pardon to my being, and if Thou keepst (this process of breathing on), then protect it with that with which Thou protected Thine pious servants."

وَحَدَّثَنَا إِسْحَاقُ بْنُ مُوسَى الأَنْصَارِيُّ، حَدَّثَنَا أَنَسُ بْنُ عِيَاضٍ، حَدَّثَنَا عُبَيْدُ اللَّهِ، حَدَّثَنِي سَعِيدُ بْنُ أَبِي سَعِيدٍ الْمَقْبُرِيُّ، عَنْ أَبِيهِ، عَنْ أَبِي هُرَيْرَةَ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَالَ ‏ "‏ إِذَا أَوَى أَحَدُكُمْ إِلَى فِرَاشِهِ فَلْيَأْخُذْ دَاخِلَةَ إِزَارِهِ فَلْيَنْفُضْ بِهَا فِرَاشَهُ وَلْيُسَمِّ اللَّهَ فَإِنَّهُ لاَ يَعْلَمُ مَا خَلَفَهُ بَعْدَهُ عَلَى فِرَاشِهِ فَإِذَا أَرَادَ أَنْ يَضْطَجِعَ فَلْيَضْطَجِعْ عَلَى شِقِّهِ الأَيْمَنِ وَلْيَقُلْ سُبْحَانَكَ اللَّهُمَّ رَبِّي بِكَ وَضَعْتُ جَنْبِي وَبِكَ أَرْفَعُهُ إِنْ أَمْسَكْتَ نَفْسِي فَاغْفِرْ لَهَا وَإِنْ أَرْسَلْتَهَا فَاحْفَظْهَا بِمَا تَحْفَظُ بِهِ عِبَادَكَ الصَّالِحِينَ ‏" ‏ ‏.‏

sunnah.com