How to Stay Awake at Night
To stay awake at night, try drinking coffee or other beverages containing caffein at regular intervals. Additionally, turn on a fan or open the windows to cool the room down, since you're more likely to sleep if it's warm. You should also get up and move around from time to time to get your blood flowing and stay alert. If you notice yourself getting drowsy, try switching to a different task that requires you to pay more attention. Alternatively, eat a healthy snack like yogurt or granola to boost your blood sugar levels, because low blood sugar can make you tired.
Take a nap beforehand if possible. If you know you're going to be up all night, then grab a nap in the afternoon. You will want to make sure that you don't sleep for too long and that you don't nap too close to when you would normally go to bed (try to take the nap 6 or 7 hours before your usual bedtime). A half hour nap is good for jump-starting your system. If you go too much over that, you'll get into a deeper sleep and will feel groggier when you wake up. If you go too much under that you won't get enough sleep to help. An hour and a half nap can help make up for lost sleep, in that you usually get through one sleep cycle in that amount of time so it can help you feel less sleepy, especially if you've been pulling a lot of all-nighters. Get some sun. Daylight (and sunlight) influence our circadian rhythms (which govern our sleep-wake cycles). So, before you pull that all-night event, spend at least 30 minutes outside in the sun and in the daylight. This (and the fresh air) will help keep your sense revitalized. Drink lots of water. Dehydration can make you feel sleepy and cause you to be tired. Combat this early, before the night sets in, by drinking lots of water. It's especially important if you're going to be drinking coffee because coffee can aggravate your dehydration, which will make you crash harder. Grab a friend. You'll stay awake much easier if you have someone to help keep your brain stimulated with conversation and presence. They can also help check that you're on track with your plan to stay awake. Drink something caffeinated. Coffee or other types of caffeinated beverages can give you a much-needed energy boost to get you through the night, especially if you pace your coffee drinking so that you don't crash heavily and painfully in those hours between 4 a.m. and 8 a.m. which is when a lot of people fail. Coffee takes about 15 to 30 minutes to kick in, but the benefits from it can last 3 to 4 hours. If you plan on drinking a cup of coffee every few hours, you'll keep pretty awake and energized. When you stop drinking your caffeinated drink, you will crash heavily. Avoid it either by spacing out coffee drinks or by utilizing other staying awake methods. If you don't want to drink caffeinated beverages, drink very cold water and sip on ice chips. The coldness can help to keep you awake and alert. Try combining caffeine with a power nap for an even bigger energy boost. Drink a cup of coffee, then immediately take a 45-minute nap. When you wake up, the coffee will start kicking in and you'll feel extra rested. Make the atmosphere cold. To sleep, your body prefers to be at a slightly warm temperature, so if the temperature of your environment is comfortably warm and cozy, it'll be harder it will be to stay awake. Turn on a fan in your room, if you can, or open the windows. If your environment is too warm and you can't cool it down enough, consider taking a cold shower. That will give you a boost of alertness. You can also apply cold compresses to your head and wrists. The best temperature range for sleeping can vary by person. On average, most people sleep best between 65 and 72 degrees Fahrenheit (18.3 and 22.2 degrees Celsius). Try a temperature just below that range, but if you're still getting drowsy, you could try playing around with the temperature more to see if you need the temperature even colder. Get up and move around. Moving around and taking a break helps get your blood flowing and keeps you from feeling sleepy. Scientists found that exercising could be more effective than some medications for increasing energy and reducing fatigue (this does not mean that you should stop taking medication if you're on some). Take breaks from your computer screen. Staring at your computer screen for hours and hours on end can cause eyestrain and make your sleepiness and fatigue worse. Relax your eyes for a few minutes each hour, either by closing them or looking at something else for a while. Exercise. Try to get at least 30 minutes of exercise. This will increase your energy level and help you stay awake. Whenever you're feeling a hit of drowsiness, go for a brisk walk or do some jumping jacks. Switch tasks. Monotonous work (doing the same thing over and over and over for an extended period of time) can be just as bad as sleep deprivation for staying alert. This means that when you feel yourself getting drowsy, switch tasks to something more difficult that requires greater concentration. Being bored can make you feel more tired. Switching tasks and moving around will keep you more stimulated and awake. Eat a healthy snack. Low blood sugar can make you super groggy and sleepy and foggy, so you'll need to keep your energy level up with healthy snacks. You especially want to eat snacks that will give you more energy to burn for a longer period of time. Eat things like yogurt and granola with fresh fruit, or peanut butter on a whole wheat cracker and celery. You'll want protein, healthy carbs (like oats), and lots of fruits and veggies. Avoid sugar. While sugar can give you an immediate burst of energy, it very quickly wears off, leaving you more fatigued and foggy than you were before. Keep the lights bright. Light stimulation to your eyes slows your biological clock. These lights hitting your receptors will delay your circadian rhythm, changing your biological clock to restart later and later. Be careful, as this may lead to a prolonged change in your sleeping schedule. 
Take a nap beforehand if possible. Get some sun. Drink lots of water. Grab a friend. Drink something caffeinated. Make the atmosphere cold. Get up and move around. Switch tasks. Eat a healthy snack. Keep the lights bright. 