أَللَّهُمَّ إِنِّي أَسْتَخِيرُكَ بِعِلْمِكَ وَأَسْتَقْدِرُكَ بِقُدْرَتِكَ وَأَسْأَلُكَ مِنْ فَضْلِكَ الْعَظِيمِ
فَإِنَّكَ تَقْدِرُ وَلَا أَقْدِرُ وَتَعْلَمُ وَلَا أَعْلَمُ وَأَنْتَ عَلاَّمُ الْغُيُوبِ أَللَّهُمَّ إِنْ كُنْتَ
تَعْلَمُ أَنَّ هَذَا الْأَمْرَ خَيْرٌ لِي فِي دِينِي وَمَعَاشِي وَعَاقِبَةِ أَمْرِي فَاقْدِرْهُ لِي وَيَسِّرْهُ لِي ثُمَّ بَارِكْ لِي فِيهِ وَإِنْ كُنْتَ تَعْلَمُ أَنَّ هَذَا الْأَمْرَ شَرٌّ لِي فِي دِينِي وَمَعَاشِي وَعَاقِبَةِ أَمْرِي فَاصْرِفْهُ عَنِّي وَاصْرِفْنِي عَنْهُ وَاقْدِرْ لِيَ الْخَيْرَ حَيْثُ كَانَ ثُمَّ أَرْضِنِي بِهِ* (قَالَ وَيُسَمِّى حَاجَتَهُ.
Allahumma inni astakhiruka bi’ilmika. wa astaqdiruka bi-qudratika, wa as’aluka min fadlika al-adheem fa-innaka taqdiru wala aqdiru, wa ta’lamu wala a‘lamu, wa anta `allamu-l-ghuyub. Allahumma, in kunta ta’ lamu anna hadhaI amra khayrun lee fee deeni wa ma’ashi wa aqibati amri (or ‘ajili amri wa’ajilihi) faqdirhu lee wa ya s-sirhu lee thumma barik lee fee-he, wa in kunta ta’llamu anna hadha-l-amra sharrun lee fee deeni wa ma’ashi wa-aqibati amri (or fi’ajili amri wa ajilihi) fasrifhu annee was-rifnee’anhu. Wa aqdir leel-khaira haithu kana thumma ardini bihi 
O Allah, I seek Your guidance (in making a choice) by virtue of Your knowledge, and I seek ability and strength by virtue of Your power, and I ask from Your great bounty that You inform me of whatever is best for me. For You are powerful, I am powerless. And You have knowledge, I know not. You know all the secrets of the unknown...
O Allah, if in Your knowledge, this [the subject matter should be specifically mentioned here] is good for me both in terms of my religion my livelihood and my affairs, my life in this world and in the Hereafter, then ordain it for me, make it easy for me, and bless it for me.
And if in Your knowledge this matter [which should be specifically mentioned here] is bad for me and for my religion, my livelihood and my affairs, both in this world and the next, then turn me away from it (and turn it away from me), and ordain for me the good wherever it may be and make me pleased with it.
Istikharah is a very important notion in Islam. It is a profound opportunity to be able to ask guidance from Allah, the knower of the unknown, regarding a specific matter.
This is why the close companions of the Rasul of Allah (saw) said, ‘Rasulullah used to advise us to do istikharah regarding all our affairs.”
Istikharah is narrated to us by many eminent companions of the Rasul of Allah (saw), including Abu Bakr (ra), Ibn Masud (ra), Abu Ayyub al-Ansari (ra), Abu Said al-Hudri (ra), Sa’d bin abi wakkas (ra) Abdullah bin Abbas (ra) and Abu Hurairah (ra):
“If any one of you is concerned about a decision he has to make, then let him pray two rakahs of non-obligatory prayer, then recite… (the prayer above).”
Chapter al-Qafirun shuld be recited after the Fatiha in the first rakah of salat and chapter al-Ikhlas should be recited after the Fatiha in the second rakah, those who do not know al-Qafirun can recite al-Ikhlas instead.
If a clear sign is not received that night, it should be repeated for seven nights until a clear and definite sign is received. The Rasul of Allah (saw) told Anas bin Malik:
“O Anas, when you attempt to do something, do istikharah seven times and then look at your heart and its inclination, for the heart inclines towards what is good.”
What about if it’s an urgent situation and there is no time for this?
Then the best thing to do is to pray two rakah salat, make repentance and then make the following prayer:
“O Allah, You are the knower of all things, the unknown, the past and the future… You also know the situation I’m currently in… Please do not leave me to my own accord, do not leave me to my self, make me incline towards what is good and ease it for me. Protect me from choosing what is harmful and close to me the way to harm. You have no partner in Your sovereignty, You are powerful over all things, I am Your servant and You are my Rabb, the Rabb of the Great Throne. Please show me the best way, inspire me to do the right thing.”
After this, place your trust in Allah and act according to how you genuinely feel.
If you happen to see a dream on the night you make istikharah where you see religious leaders and saints, or colors such as white and green, it is a positive sign, but if you see colors, such as black, blue or yellow, it is generally a negative sign.
Istikharah is especially recommended to Sufi aspirants to protect them from knocking on the wrong doors.
Some even make istikharah to ask about their spiritual state, somewhat like an auto-control to keep themselves in check.
However, let us never forget that:
There are things that seem good for us, that we may want with an utmost desire, yet they may actually be harmful for us…
And there are things that seem harmful, that we resist with persistence, but they may actually be good for us in the reality… Only Allah knows, we know not…
One who asks Allah will never feel regret.
 Sahih al-Bukhari, al-Tirmidhi.