Japan is unique country in the fact that the mass rail transportation is very highly developed. This means that you are highly likely to rely on the train network in order to commute to your workplace or university campus. The good news is, the train network in Japan is so highly developed that you can travel to most places with the train, and usually a station is within 10 minutes away. Unfortunately, since the train network is so developed, everyone ends up using it, so overcrowding is not an uncommon thing within the Japanese (especially Tokyo) society. Fortunately, there are steps that can be taken in order to make the rush hour less of a stressful experience.
1. Identify and understand the rush hour
The first usually comes with experience, but is otherwise necessary if you want to steer away from the rush hour. Different lines have different loads. For example, the Tozai line during the rush hour is usually going to be more crowded than, say, the Ginza line. The reason for this is that many people who commute to work live outside of Tokyo into the suburban areas, as land inside the city tends to be expensive. Related to this is where the crowd generally moves. During the morning rush hour, trains going to inside the city tends to be the most crowded ones, whereas trains moving outside the city will be relatively empty. The opposite is true during the evening rush hour, as trains moving outside the city will generally contain much more people than trains moving into the city. Another thing to note is the period of time where rush hour begins and ends. The morning rush hour tends to be shorter than the evening rush hour, but more intense. The evening rush hour is generally more spread out. The time period varies, but the morning rush hour generally begins from 7:30 until around 9, and is most intense at 8 AM. The evening rush hour starts at around 6 and ends late in the night at around 9. Keep in mind, however, that the exact timing varies depending on the line, which is why experience is often times required in order to make decisions on avoiding the rush hour.
2. 先発/始発 trains
I was lucky to have lived in a station where empty trains come and leave from the station. This means that I can simply take the trains that leave from the station rather than ones originating farther away. If you are lucky or have queued up early enough, you can even guarantee a seat every single time. This is, however, fairly situational and often times impossible depending on where you live. However, if you live in a station or two away from where trains originate, it might be a good idea to take a train to that station and then transfer to the train originating from the station. It might cost you some time, but if you can net yourself a seat, then it might be worth the extra time.
3. Avoid the center of the carriage
Most of the squishing and harassment occurs if you stand in the center of the carriage, or near the doors. The sidelines next to the seats, on the other hand, tends to be less of a squishy experience than the center. If you happen to get the chance, always try to stand next to the seats.
4. Observe which carriages tend to be most crowded
Not all carriages are popular. People tend to stick to the carriage that is closest to the exit of their destination. If that destination is popular, then that carriage will usually be crowded. Again, this comes to experience and observation, and the best way to find out is usually just going in different carriages every day and notice which carriage feels less crowded. On the other hand, it might be worthwhile sticking to the carriage closest to the most popular exit of the station that you are heading towards because it is easier to get out that way.
5. Wait for the next train
Delays happen, whether it be two minute long delays or ten minute long delays. During the rush hour, unloading and loading takes more time due to the sheer amount of passengers that the train handles, which is why the train schedule in the morning is sometimes irrelevant during the rush hour. During the evening rush hour, however, since the rush hour is generally more spread out, when a train is delayed, you should probably wait for the next train. The train that is delayed would often times carry a lot more passengers than normal and the train following it would have less traffic.
6. Take the local train
Usually the rapid and express trains carry more people. If you are willing to sacrifice time, then taking the less popular local train may be a decent option. If, however, time is valuable and/or you live very far away, then this may not be a feasible option. This also only holds true if you are not taking Tokyo Metro lines, as very few Tokyo Metro lines have rapid services and it probably would not make much of a difference anyway.
Ultimately, dealing with the rush hour comes in 2 ways: either you stubbornly refuse to cope with the rush hour and try to find ways to avoid it or make it as painless as possible, or accept it as part of your lifestyle. If you are the former and the steps that were mentioned are not working out, then changing your schedule or seeking other methods of transportation may be the final solution. I, myself, got tired of dealing with the evening rush hour and decided to move closer to the campus where I can bike within half an hour. If none of these work, then submitting to the rush hour and letting your body adapt to the mass of salarymen heading towards their workplace might be the only last solution.