The Prophet ﷺ as saying: If anyone fasts during Ramadan because of faith and in order to seek his reward from Allah, his previous sins will be forgiven to him. If anyone prays in the night of the power (lailat al-qadr) because of faith and in order to seek his reward from Allah his previous sins will be forgiven for him. Abu Dawud said: This tradition has been transmitted in a similar manner by Yahya b. Abi Kathir and Muhammad b. 'Amr from Abu Salamah.
النَّبِيَّ ﷺ مَنْ صَامَ رَمَضَانَ إِيمَانًا وَاحْتِسَابًا غُفِرَ لَهُ مَا تَقَدَّمَ مِنْ ذَنْبِهِ وَمَنْ قَامَ لَيْلَةَ الْقَدْرِ إِيمَانًا وَاحْتِسَابًا غُفِرَ لَهُ مَا تَقَدَّمَ مِنْ ذَنْبِهِ