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:35:38

Indeed, Allah is Knower of the unseen ˹aspects˺ of the heavens and earth. Indeed, He is Knowing of that within the breasts.  

Truly God is Knower of the Unseen of the heavens and the earth; truly He knows well what is in the breasts, what is in the hearts — thus there is all the more reason that He should ˹also˺ have knowledge of other things, given the way people are.
القرآن:٣٥:٣٨

إِنَّ اللَّهَ عَالِمُ غَيْبِ السَّمَاوَاتِ وَالْأَرْضِ ۚ إِنَّهُ عَلِيمٌ بِذَاتِ الصُّدُورِ  

{إن الله عالم غيب السماوات والأرض إنه عليم بذات الصدور} بما في القلوب، فعلمه بغيره أولى بالنظر إلى حال الناس.

See similar narrations below:

Collected by Qurʾān
quran:64:4

He knows what is within the heavens and earth and knows what you conceal and what you declare. And Allah is Knowing of that within the breasts.  

He knows all that is in the heavens and the earth, and He knows what you hide and what you disclose, and God is Knower of what is in the breasts, in terms of the secrets and convictions they contain.
القرآن:٦٤:٤

يَعْلَمُ مَا فِي السَّمَاوَاتِ وَالْأَرْضِ وَيَعْلَمُ مَا تُسِرُّونَ وَمَا تُعْلِنُونَ ۚ وَاللَّهُ عَلِيمٌ بِذَاتِ الصُّدُورِ  

{يعلم ما في السماوات والأرض ويعلم ما تسرون وما تعلنون والله عليم بذات الصدور} بما فيها من الأسرار والمعتقدات.