In the times of the Beit Hamikdash, a person who survived a potentially life-threatening situation brought a Korban Todah, a Thanksgiving Offering, to express his gratitude to Hashem. Nowadays, when the Beit Hamikdash no longer stands and offerings cannot be brought on the altar, we substitute a public proclamation of gratitude to Hashem for an offering. A survivor from a life endangering situation as defined by the Gemara recites Birkat Hagomel in gratitude.
- The Gemara Brachot 54b states: "One who has completed a sea voyage; one who has traveled through the desert; one who has been sick and healed; and one who was imprisoned and freed."
- According to the Magen Avraham,  Birkat Hagomel, like the Korban Todah, is non obligatory but rather optional. The Peri Megadim  argues that it is obligatory. Nevertheless, all poskim urge one to be careful to fulfill this mitzvah given the opportunity. 
- Given that Birkat Hagomel is a public expression of gratitude, it cannot be said in private.
- Vayikra 7:12
- OC 219:1
- OC 219:1
- Chasam Sofer O.C. 51, Minchas Yitzchok 4:11-9