I've answered this question a while ago - Is developer burnout real? If yes, what may be the cause?, but I will share it here too.
It may sound easy, but finding the right balance is something that takes time and dedication to achieve. If we manage to treat our work as everything else and find more time for other activities and hobbies, burnout wouldn't be a problem anymore.
Step back and take a break
If you find yourself in a situation of burnout, step back. Take 2-3 days and give yourself a break from the computer. Do a little trip or go to a concert. Whatever you decide to do, don't associate it with our work.
Work on side projects
This is what helped me over the last three years to overcome burnout. Working on side projects brings many positive emotions and stimulations. You don't have deadlines, technology limitations or decision breakers. It's a wonderful way to work on whatever you want, whenever you want.
Live healthy and exercise
Feed your body, feed your soul. When exercising, your body releases endorphin, a chemical that interacts with the receptors in your brain that reduces the perception of pain. Endorphins also trigger a positive feeling in the body, similar to that of morphine. It reduces stress and anxiety and boost self-esteem and can improve sleep.
Also, decrease the junk food and the calories you eat on a daily basis. Start eating more vegetables and don't overeat.
Also, you should find enough time for sleep, at least 7-8 hours a day. Good sleep can boost your energy and increase your productivity and mood. Meditation is also something you can consider. Again, taking a break from the everyday thoughts can also boost your overall mood and sense of accomplishment.