A study of university women showed that after an hour and a half on Facebook, they began to feel bad about their bodies. Most of the students wanted to lose weight and seeing pictures of people they knew affected their idea of the"perfect body" more. Being photos of friends caused even more harm than seeing photos of celebrity bodies, as they were people close to them.
Although the study was conducted with women, many men also go through this. You don't need to stray from social networks, but you do need to learn to control how long you're on them, especially if you've already acknowledged that they're hurting you. An alternative way to stay on social networks without affecting your self-esteem is to look for people or groups with the same interest as you. There are groups for all kinds of interests: cooking, fitness, health, fashion, beauty, etc.
Try to follow only the kind of person who will help you to have confidence in yourself, make you laugh, inspire you to eat better, exercise and overcome your insecurities.