Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:41:46

Whoever does righteousness - it is for his ˹own˺ soul; and whoever does evil ˹does so˺ against it. And your Lord is not ever unjust to ˹His˺ servants.  

Whoever acts righteously, it is for ˹the good of˺ his own soul, that he acts ˹thus˺, and whoever does evil, it is to the detriment thereof, in other words, the harm consequent from his evildoing will ˹only˺ be to him. And your Lord is not ˹at all˺ a tyrant to His servants, that is, He is not One of injustice, as He, exalted be He, says: Surely God shall not wrong so much as the weight of an atom ˹Q. 4:40˺.
القرآن:٤١:٤٦

مَنْ عَمِلَ صَالِحًا فَلِنَفْسِهِ ۖ وَمَنْ أَسَاءَ فَعَلَيْهَا ۗ وَمَا رَبُّكَ بِظَلَّامٍ لِلْعَبِيدِ  

{من عمل صالحاً فلنفسه} عمل {ومن أساء فعليها} أي فضرر إساءته على نفسه {وما ربك بظلام للعبيد} أي بذي ظلم لقوله تعالى (إن الله لا يظلم مثقال ذرة).

See similar narrations below:

Collected by Qurʾān
quran:45:15

Whoever does a good deed - it is for himself; and whoever does evil - it is against the self. Then to your Lord you will be returned.  

Whoever acts righteously, it is for ˹the benefit of˺ his own soul, that he acts ˹so˺, and whoever does evil, it is to the detriment thereof, that he has done evil; then to your Lord you will be returned, ˹with your Lord˺ you shall end up, whereupon He will requite the one of righteous deeds and the evildoer.
القرآن:٤٥:١٥

مَنْ عَمِلَ صَالِحًا فَلِنَفْسِهِ ۖ وَمَنْ أَسَاءَ فَعَلَيْهَا ۖ ثُمَّ إِلَىٰ رَبِّكُمْ تُرْجَعُونَ  

{من عمل صالحاً فلنفسه} عمل {ومن أساء فعليها} أساء {ثم إلى ربكم ترجعون} تصيرون فيجازي المصلح والمسيء.