Allah says in the Quran:
… the Day when neither wealth nor children will be of any benefit. Only those who come before Allah with a pure heart will be saved. 
The verse quoted above emphasizes the importance of purifying our hearts in this life as it is the key to our success in the Hereafter. According to this verse, on the Day of Judgment, our wealth and children will be of no use to us, and the only thing that will benefit us is a pure heart.
As Muslims, it is essential to heed this call and strive to purify our hearts of negative qualities such as sin, malice, envy, worldliness, greed, and arrogance. Instead, we should replace these negative traits with positive qualities such as generosity, compassion, benevolence, and gratitude.
The first commandment with which Prophet Musa (PBUH) was sent to Pharaoh was the purification of the heart.
Allah said: “Go to Pharaoh, for verily, he is a transgressor. Say to him: ‘Will you purify yourself?'” 
Prophet Ibrahim’s (PBUH) defining characteristic was his pure heart:
Verily, among his people was Abraham, when he came to his Lord with a pure heart. 
Thus, the purification of our hearts holds an important position in our life and the Hereafter. So, some of the steps we could take on to purify our hearts are as follows:
1 Prioritizing the Five Obligatory Prayers
Islam has five basic pillars namely, Tawheed( Oneness of Almighty), Namaz, Roza, Zakat and Hajj. The second pillar of Islam, Namaz, also known as prayer, holds great significance in the Islamic faith. It is considered an act of submission to Allah and offers numerous benefits to those who perform it regularly. Namaz helps individuals build a connection with Allah, and through this connection, they are able to draw closer to their Lord and obtain a pure heart.
While there are no restrictions on invoking Allah, Namaz is considered the preferred way of doing so. This is because through Namaz, one is able to establish a deeper connection with Allah and any invocation made within this state of devotion is more likely to be accepted by Allah compared to other circumstances.
O you who have believed, seek help through patience and prayer. Indeed, Allah is with the patient. 
We are exposed to environments and people which significantly impact our souls and hearts. Undoubtedly the current plight of the people of the world is miserable where they are more attracted towards ills and lewdness compared to goodness, which makes our hearts ill and damaged and impure thus, we can quickly go down the road of darkness. So to prevent ourselves from being a companion of Satan, Namaz is what we need to hold on to and find refuge in it.
Recite, [O Muhammad], what has been revealed to you of the Book and establish prayer. Indeed, prayer prohibits immorality and wrongdoing, and the remembrance of Allah is greater. And Allah knows that which you do. 
2 Read the Holy Quran
Standing for prayer is a way to connect with Allah and submit ourselves to His guidance. Through reading the Quran, we receive direct guidance from Allah and learn more about His attributes and the favors He has bestowed upon us. This knowledge helps us develop a love for Allah and purify our hearts. The Quran also teaches us about the Prophets and the messages they brought, which strengthens our faith and increases our understanding of Allah’s plan for us.
A Book We have sent down to you so that you may bring forth mankind from the darkness into the light…. 
3 (Dhikr) – Remembrance of Allah
As per Sunnah (Prophet’s method), one of the primary methods of purifying our hearts is the sincere remembrance of Allah.
He has succeeded who purifies himself, who remembers the name of his Lord and prays. 
Asking for forgiveness through invocation helps to humble us and rid our hearts of arrogance. When we pray for guidance for others, it helps to cultivate compassion within us and remove malice and hatred from our hearts. Reflecting on the Day of Resurrection reminds us to prioritize our actions in this world and be kind to others for the sake of Allah. These practices help us become better individuals and strengthen our connection with Allah.
In this way, we can purify our hearts every morning and evening through remembrance of Allah.
Verily, the prayer prohibits immorality and wrongdoing, and the remembrance of Allah is greater. 
4 Call Upon Allah Using Asma-ul-Husna
Asma-ul-Husna refers to the names of Allah, as we know there are ninety-nine names of Allah. These are not just names. These are his attributes. So when we invoke Him with these beautiful names, we get closer to Him.
And the Most Beautiful Names belong to Allah, so call on Him by them. 
When we ask Allah through His names, we get to know how great our Lord is, and we feel much closer to him, which purifies our hearts.
5 The Power of Dua (Supplications)
Anas bin Malik narrated that:
The Prophet Muhammad (PBUH) said: “The supplication is the essence of worship.” 
Making Dua to Allah for purifying our hearts is undoubtedly the best method. If Allah did not want you to have a pure heart, he would not have guided you to make dua for one.
An-Numan bin Bashir narrated that:
The Prophet Muhammad (PBUH) said: “The supplication is worship.” Then he recited: And Your Lord said: “Call upon me, I will respond to you.” 
6 Be Optimistic
It is important to maintain a calm and composed demeanor when dealing with situations that have yet to come to fruition. It is wise not to burden oneself with unnecessary questions of how, what, and when, and instead trust in Allah’s pre-ordained plan for us. Negative thoughts, particularly regarding our future, should be avoided, as Allah (SWT) loves us and has a plan for our lives. To achieve personal growth and betterment, we must remain optimistic, reject feelings of hopelessness, and practice patience, prayer, and hard work. Ultimately, it is crucial to hold a reasonable and positive opinion of our Lord.
Verily, to be hopeful of Allah’s mercy opens the doors of optimism for one of His slaves, making him more avid in worship and inspiring him to be more enthusiastic in performing voluntary acts of worship and racing to perform good deeds. 
When we are reminded of Allah’s Mercy, Forgiveness, and Generosity, we are moved to do good deeds. As a consequence of reflecting on these qualities, they seek closeness to Allah through diligently performing good acts. Consequently, we get our hearts purified.
7 Be Thankful, Be Charitable
So hold that which I have given you and be of the grateful. 
It is important to cultivate contentment with whatever blessings we have received in life. This way, we can fill our hearts with feelings of gratitude and joy, leaving no room for negative emotions like malice, arrogance, hatred, or greed. This, in turn, leads to a purified heart.
Our true worth lies in our abilities, good deeds, manners, and contributions to society. It is not wise to dwell on external factors such as physical appearance, wealth, or family background. Instead, we should learn to be happy with what Allah (SWT) has allotted for us.
Engaging in charitable activities is an excellent way to remain humble and compassionate. Seeing those who are less fortunate than ourselves can remind us of the countless blessings we have received from Allah (SWT). As a result, we become more grateful and content, focusing our attention on pleasing Allah. When we feel content, we are not consumed by regrets of the past or anxiety about the future. Our sole concern becomes ensuring that we are pleasing Allah (SWT) with our actions. Let us, therefore, strive to cultivate contentment in our hearts and lead a fulfilling life in the eyes of our Lord.
Allah (SWT) describes a purified heart as being thankful:
Allah does not wish to impose hardship upon you. Rather, He wishes to purify you, and to complete His blessings upon you; and so that you may be thankful. 
The ultimate success of a Muslim depends on the purification of their heart and soul from negative qualities, and the cultivation of virtuous traits. Engaging in sincere supplication, prayers, and charitable acts towards others can help purify our hearts.
As Muslims, we must keep in mind that we will face Allah (SWT) on the Day of Resurrection and be judged based on the purity of our hearts and the righteousness of our deeds. Therefore, it is essential to focus on our spiritual well-being and strive to improve our character and actions.
Purifying the heart involves ridding ourselves of negative traits such as envy, greed, and arrogance, and replacing them with positive qualities such as humility, generosity, and compassion. Regular acts of worship, including Salah, Zakat, and Sadaqah, can help us achieve this goal.
Let us all make a conscious effort to purify our hearts and souls, seeking the pleasure of Allah (SWT) in all that we do. May He guide us on the path of righteousness and grant us success in this life and the hereafter.
- The Quran, 26:88-89 (Surah Ash-Shu’ara)
- The Qur’an, 79:17-18 (Surah An-Naziat)
- The Qur’an, 37:83-84 (Surah As-Saffat)
- The Quran 2:153 (Surah Al-Baqarah)
- The Qu’ran 29:45 (Surah Al-Ankabut)
- The Quran 14:01 (Surah Ibrahim)
- The Qur’an, 87:14-15 (Surah Al-A’la)
- The Qur’an, 29:45 (Surah Al-Ankabut)
- The Quran 07:180 (Surah Al-A’raf)
- Jami at-Tirmidhi, Book 48, Hadith 2
- Jami at-Tirmidhi, Book 48, Hadith 3
- Al-Awasim wa al-Qawasim, Book by Ibn al-Wazeer
- The Quran 07:144 (Surah Al-A’raf)
- The Quran 05:06 (Surah Al-Mai’dah)