Saying Modeh Ani:
Immediately upon awakening, even prior to washing ones hands, it is proper to [accustom oneself to] say Modeh Ani. [This is done in order to remember that Hashem is standing over him and motivate him to get up with alacrity. Alternatively it is done in order to thank Hashem immediately upon awakening for the pleasure received in having his soul returned.]
Immediately upon awakening, prior to washing ones hands, one should place one hand against the other, lower his head, and say Modeh Ani. One should say it while still sitting or lying on his bed, and not while standing. One who sits up on his bed is to do so without placing his feet on the ground.
May one say Modeh Ani if he has feces on his body or within four cubits of himself?
May one say Modeh Ani if he smells feces such as from the diaper of a child?
Child can eat grains: If the child is old enough to consume a Kezayis [27 grams] of grains, such as porridge, then it has the same ruling as explained in the previous Q&A.
Child cannot eat grains: If the child is not yet old enough to consume a Kezayis of grains then it is permitted to say Modeh Ani in his presence.
 Siddur; Basra 1/6; Kama 1/5; Bier Heiytiv 1/5; M”B 1/8 based on Seder Hayom; Siddur Yaavetz Hashkamas Haboker 3; Siddur Haarizal; Ateres Zikeinim. Not mentioned in Tur, Shulchan Aruch, Taz or Magen Avraham.
Background of Modeh Ani:
When did the recital of Modeh Ani begin?
In Talmudic times, Modeh Ani was not recited. The reason for this is because they were able to recite the entire blessing of Elokaiy Neshama upon awakening, due to lack of impurity. There was thus no need to recite Modeh Ani as in Modeh Ani there is nothing new or additional to the blessing of Elokaiy Neshama. Saying Modeh Ani is only required in our times being we cannot recite Elokaiy Neshama due to the impurity, and it is thus said in order that the thanks be given immediately upon awakening from sleep. [“On the Essence of Chassidus” p. 58 based on Rabbeinu Yonah in Brachos 60b; Shulchan Menachem 1/1] There is likewise no mention of Modeh Ani in the Rambam as he simply rules [Hilchos Tefilah 7/3] that as soon as one awakes he should say Elokaiy Neshama.
The first source: The first source which records the custom to recite Modeh Ani is the Seder Hayom. [Authored by Moshe Makir Tzfas 1600] To note from Siddur Yaavetz 3 “The sect of later Chassidim have added on their own accord to say Modeh Ani upon awakening”. This implies that even in the 1700’s the idea of saying Modeh Ani was not yet widespread.
 Kama 1/5, Basra 1/66, and Siddur state that it may be said prior to washing hands; Hayom Yom 11th Shvat and Rebbe in Igros Kodesh 10/23 [28th Tishreiy 5715] state that it is specifically to be said prior to washing. So is also implied from the term “immediately” used in Admur and from fact that Admur in both SH”A and Siddur explains why this can be said prior to washing. This is also understood from the fact Admur in his Siddur placed the saying of Modeh Ani prior to Netilas Yadayim. [ibid]
The reason Modeh Ani is allowed to be said prior to washing hands: There is no prohibition in saying Modeh Ani prior to washing hands, despite that in general it is forbidden to bless G-d before washing, as there is no mention of one of the seven names of G-d in this statement [Kama 1/5; Basra 1/6; and Siddur] and therefore this statement is not considered to contain the holiness required for clean hands. [Kama ibid] This allowance to recite Modeh Ani before washing hands applies even if one slept without clothing and hence most probably touched areas of his body that are normally covered. [Basra 1/6]
Other Opinions: Some Poskim [Yaavetz in his Siddur Hashkamas Haboker 4; opinion in Chida in Kesher Gadol 1/1; Rechev Eliyahu and Minchas Aron brought in Igros Kodesh 10/23] rule one is to only say Modeh Ani after washing hands. Practically we rule as above that Modeh Ani precedes washing of the hands as so is the ruling of most Poskim. [Igros Kodesh ibid; Kaf Hachaim 1/4; Piskeiy Teshuvos 1 footnote 28 writes that the Yaavetz is the sole opinion who holds that Modeh Ani is to be said after washing, however as brought above there are other Poskim which agree to his ruling.]
 Lit. Tov [Siddur, and Shulchan Aruch in both versions]
 Basra 1/6 and Siddur
 Other Verses: Some write that one is to also say the verse of “Baruch Shenasan Torah Liamo Yisrael” [Siddur Yaavetz; Siddur Daas Kedoshim] and the prayer of “Yehi Ratzon Milifanecha Sheyihei Libi Nachon…” [Siddur Yaavetz ] This is not our custom.
 Siddur and Basra 1/6
 Shulchan Menachem 1/1; It is necessary to thank Hashem immediately upon awakening being that every blessing needs to be said in close proximity to the pleasure received. In “The essence of Chassidus” chapter 10 the Rebbe explains this to be the level of Pshat of the meaning behind Modeh Ani.
The level of Remez: The recital of Modeh Ani alludes to the resurrection, as just like we see that after sleep our soul is returned so too the dead will eventually have their soul returned. This then is the Remez meaning of Modeh Ani ”that you have returned my soul [and hence] I believe [in the resurrection]”. [See Midrash Eicha 3/23]
The level of Drush: The message that Modeh Ani teaches a Jew is with regards to returning collateral of a debt to its owner. Just like Hashem returns our soul which he could choose to “collect” due to our many “debts” so too we should act accordingly to others and return collaterals that they gave us in exchange for loans. [See Midrash Eicha 3/23]
The level of Sod: According to the “esoteric” part of Torah, Modeh Ani is explained in the following manner: the words “living and eternal King” refer to the Divine attribute of Malchus as it is united with the attribute of Yesod. The word melech, King , indicates
G-d’s attribute of Malchus, and “living and eternal” His attribute of Yesod. “Living and eternal King who has restored my soul within me” means, then, that the restoration of the soul comes from the level of Malchus as it unites with the level of Yesod. [See Shaar Hakavanos Drushei Halayla]
The level of Chassidus: See “Sparks of Chassidus”. For a thorough explanation of the Chassidic addition to all previous four explanations, see “On The essence of Chassidus” chapters 12-15.
[On the Essence of Chassidus p. 58-60]
 Piskeiy Teshuvos 1/5
 As one may not think of Torah and Mitzvos while he has feces on him. [See Admur 85/1] The same prohibition applies with regards to thinking about Hashem [Rebbe in Hisvadyos Naso 1983 p. 1601; Lehoros Nasan 1/1; Tzitz Eliezer 13/; Levushei Mordechai 171; See Vayivarech David 15; This is also implied from the fact that in 85/1, the Halacha dealing with what one should think about in a bathroom, no mention is made of thinking about G-dliness.]
Analysis on above: Vetzaruch Iyun from the fact that it is permitted to mention Hashem in a bathhouse so long as one does not mention one of His seven names, and hence one may say Chanun or Rachum [the merciful one]. [85/2] Thus seemingly the same would apply here that it is permitted to say Modeh Ani in an impure area [near feces] being that one is not mentioning any of Hashem’s Divine names. [Accordingly the above Poskim only forbade contemplating about Hashem in an impure area while simply mentioning Him they would allow.] On the other hand however there are Poskim who rule that even Chanun and Rachum may only be said if it does not refer to Hashem himself and one is using it to refer to another person. [Kaf Hachaim 85/12 in name of Gur Aryeh] Likewise the Peri Megadim [85 A”A 3] rules that one may not pray in a bathroom using the names Rachum Vechanun. Vetzaruch Iyun as to the opinion of Admur [based on his wording in 85/2] in all this.
 Eretz Tzevi 1/52 [Appendix]
 His reasoning is because it is permitted to mention Chanun Verachum in a bathroom being that one is not explicitly mentioning Hashem’s name. Hence we see one may think about Hashem. The same would then apply with Modeh Ani of which one thinks about Hashem but does not mention any of His names. He explains the reason it is permitted to think about Hashem is because one’s body figuratively covers the words and it is as if the feces is covered. This is not similar to thinking words of Torah near feces which is forbidden being that when thinking Torah one’s entire body becomes like a vessel for Torah as is learned from a verse in the Talmud. [ibid; see there in which he bases some of his logics on Tanya]
 Based on 81/1