The work Seder Hayom mentions the well-known practice of reciting "Modeh Ani" immediately when one wakes up in the morning to thank G-d for returning his soul, which left him as he slept. One does not have to wash Netilat Yadayim before reciting "Modeh Ani," because even if his hands are dirty, he is allowed to recite this brief prayer, which does not include any Names of G-d.
The custom of reciting "Modeh Ani" is mentioned in several other sources, as well, including the Kav Ha’yashar (chapter 1), who emphasizes the importance of beginning the day with Kedusha. The Hida (Rav Haim Yosef David Azulai, 1724-1806) records this custom in his work Kesher Agudal (1:1).
Should a person recite "Modeh Ani" if he remained awake throughout the night, and did not sleep?
Interestingly enough, the Kabbalists write that even when a person is awake during the night, his Neshama (soul) ascends to the heavens, either to make a reckoning for one’s actions during the day, or to benefit from the radiance of the Divine Presence. This is mentioned by Rav Abraham Azulai (1570-1643), in his work Hesed Le’Abraham (4:45). Rabbi Raphael Sharabi (1775-1827; he was the grandson of the famous Rabbi Shalom Sharabi) writes that for this reason a person feels tired and weak when he remains awake at night, often to the point of being unable to stand up straight. This occurs because part of his soul ascends to the heavens (listen to audio recording for precise citation).
Therefore, the Kabbalistic works say that even if a person stays up throughout the night, he should nevertheless recite "Modeh Ani" in the morning, before Birkot Ha’shahar, because his soul had ascended to the heavens during the night. This is the ruling of Hacham Bentzion Mutzafi (contemporary), in his work Orehot Siyon (1:129; listen to audio recording for precise citation).
Summary: Even if one remained awake throughout the night, he should nevertheless recite "Modeh Ani" in the morning before Birkot Ha’shahar.