Short answer
Saying it aloud inside a toilet is makruh. Say bismillah and the bathroom dua just before you go in. If you are already inside, for example for wudu in a bathroom with a toilet, say it silently in your heart. The four schools agree that dhikr in the toilet is disliked.
Dhikr and reciting the Quran aloud in a toilet are makruh. The sunnah is to say bismillah and the dua before entering, and "ghufranaka" after leaving. Taking a copy of the Quran or anything with Allah's name uncovered into the toilet is makruh tahrimi.
The four schools agree on this.
Explanation
The Prophet ﷺ would say a dua seeking refuge from evil and impure beings before entering the place of relieving himself, and after leaving he would say "ghufranaka" (I ask Your forgiveness). A man greeted him while he was urinating and he did not reply until he had made wudu, explaining that he disliked mentioning Allah except in a state of purity.
So the four schools agree that dhikr inside the toilet is makruh (disliked), out of respect for the name of Allah. In practice:
- Say bismillah and the dua at the door, before you step in with your left foot.
- If you forgot, say it silently in your heart once inside. Moving the tongue is not needed.
- If you sneeze, praise Allah in your heart.
- Do not reply to a salam or chat while relieving yourself.
Modern bathrooms often have the toilet, sink and shower in one room. When you make wudu there, say bismillah before entering, or in your heart. Some Hanafi scholars say that once the toilet area is clean and you are at the sink, the room is lighter in ruling, but saying it in the heart is the safer way.
Phones with Quran apps are fine in your pocket as long as the screen is not open on the Quran. Jewellery with Allah's name should be covered or kept in a pocket. See the duas for entering and leaving the bathroom.
The evidence
Sahih al-Bukhari 142
Sahih... اللهم اني اعوذ بك من الخبث والخبائث ...
"O Allah, I seek refuge in You from evil and impure beings."
The dua said before entering the toilet.
Sunan Abi Dawud 17
Graded sahih... اني كرهت ان اذكر الله عز وجل الا على طهر ...
"I disliked mentioning Allah except in a state of purity."
The basis for avoiding dhikr while relieving oneself.
Jami' at-Tirmidhi 7
Graded sahih... اذا خرج من الخلاء قال غفرانك ...
"When he came out of the toilet, he would say: I ask Your forgiveness."
What to say when leaving the toilet.
Where the ruling is recorded
- Radd al-Muhtar (Ibn Abidin), Kitab al-Taharah, etiquette of relieving oneself. Dhikr inside the toilet is makruh; saying it in the heart.
- Nur al-Idah with Maraqi al-Falah, Chapter on the etiquette of relieving oneself. The sunnahs of entering and leaving the toilet.
This answer is pending review by the scholars on our team. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.