A phrase (attached typically after a verb's -masu stem or stem of an adjective) meaning 'to almost do something' or 'to be about to happen'. Used for events or emotions that nearly occur.
映画の最後で感動して泣きそうになった。
I was moved at the end of the movie and nearly cried.
夜遅くまで仕事をしていて、椅子で寝そうになった。
I worked late into the night and was about to fall asleep in my chair.
うっかりしていて危うく電車にひかれそうになった。
I was careless and was almost hit by a train.
お腹が空いてついお菓子を食べそうになるが、ダイエット中なので我慢した。
I was so hungry that I was about to eat a snack, but I restrained myself because I'm dieting.