Well, you aren't alone. A recent set of data released by Jawbone UP, a fitness tracking device, suggests that human sugar cravings peak around midnight.
But why? Well, the well known journal called Obesity has a theory. In the journal, authors suggest that cortisol levels usually push the liver to release glucose at night when we sleep, as we need energy during the night when we do not eat. Usually the level of cortisol is just enough to achieve this. But when we are awake at night a surge in cortisol occurs, that might cause the hunger pangs.
Studies have also shown that the levels of leptin, an appetite controlling hormone are least at night because of exhaustion. And this hormone lack may trigger craving for calorie rich food. Another study suggests that the areas of the brain important for self control is weak at night and this may too explain why sleepless people are prone to the midnight snack effect!