The nerd posture, the rounded shoulders and the head that hangs out in front of the body. If you look around you are going to see this a lot. Almost everyone has it.
The good news is that it is actually correctable, contrare to popular belief it is not a permanent and irreversible state, the body is adaptable it constantly molds and shapes itself based on the pressure you subject it to.
So the first obvious thing to do is to stop sitting so much, not only sitting is causing you to develop muscular imbalances that give you the bad posture but it also cause your body to atrophy, effectively loosing muscular and bone tissue do to not being used for most of the day.
Because there is the appearance of leaning forward, the common wisdom in correcting this kind of problem is to stretch the front of the neck and the shoulders. However this is completely opposite to what needs to happen.
Recommending exercise like chin retractions, and shoulder stretches is counter productive. The front of the neck and the shoulders are already loos they don't need to be stretched.
Whenever you sit the back of your neck becomes tight, not the front.
Sitting on the part of your pelvis that is called the sitting bones it is rather uncomfortable, what most people are going to do is rol their pelvis back supporting their body on the sitting bones and the coccyx.
This causes the back to round in to a c shape, and in order to be able to look straight in front, you have to lift your head up by using the muscles in the back of your neck. Putting an abnormally high load on those muscles causing them to shorten, which makes your body hold the same posture even when you are not sitting.
There is a very simple way to check this: standing in front of a chair put one of your hand in the back of your neck. Touch the base of your skull with your pinky and the base of your neck right where your shoulders start with your thumb. Holding the hand in place, sit down as if you would normally.
This should allow you to feel your body shifting. What happens with the space between your head and shoulders. Does it get longer or shorter?
Another way to observe this is to look at old people, as they have accumulated lots of sitting hours and the skin attaches to the muscles, you can see the tonus in the muscles based on how tight or loos the skin is. Does the front of an old person neck looks tight or loos?
So I hope that this convinces you that is the back of your neck that requires intervention not the front.
There is a very simple stretch that can increase the length of the muscles in the back of your neck, that is chin to chest stretches.
Standing with your feet at shoulder length, move your chin down as if you would try to touch your chest with it, until you feel the stretch in the back of your neck and maybe a little on the top of your shoulders. Holding this for as long as possible I recommend at least 3 hours per day for fast results.