Abu Hurairah reported,

The Messenger of Allah ﷺ prayed over a funeral and said, "Allah, forgive our living and our dead, our young and our old, our males and our females, those of us present and those absent. Allah, whoever among us You keep alive, let him live in faith, and whoever among us You take in death, let him die in Islam. Allah, do not deprive us of his reward, and do not lead us astray after him."

Azami 3713

Sahih

عن أبي هريرة قال

صلى رسول الله ﷺ على جنازة فقال: اللهم اغفر لحينا وميتنا، وصغيرنا وكبيرنا، وذكرنا وأنثانا، وشاهدنا وغائبنا، اللهم من أحييته منا فأحيه على الإيمان، ومن توفيته منا فتوفه على الإسلام، اللهم لا تحرمنا أجره، ولا تضلنا بعده.

الأعظمي 3713صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Funerals
Chapter
Prayer over the deceased
Section
Supplications over the funeral
Numbering
Jami al-Kamil 3713 (2nd edition)
Azami 3713