As someone who has experienced it almost every day going to school, there’s no doubt that Japan’s morning rush is intense. Especially if there are delays, people are willing to push their way into a train even if it seems virtually impossible in order to get to work on time. Not just mornings though, it could happen later in the evenings when people are heading home, or when huge events like firework festivals and soccer games are taking place.
In any case, the best advice I can give is to stay calm and be mindful of others.
If you have a backpack, for example, a pro tip is to take it off and hold it against your chest. This way, you give a little more space to the person behind you, which is a very thoughtful gesture.
Also, when boarding, walk as far into the train as possible to fill any open spaces. You definitely don’t want to stand in front of the doors where you might block the flow of people going in and out. Neither should you stop halfway down the aisle (when you could move further in), because that would create unnecessary empty pockets and cram certain areas.
Final important point. Unfortunately, it’s common for ill-intentioned people to take advantage of the congestion in public transport to grope other passengers (primarily women). Be very mindful of where you’re putting your hands to avoid any misunderstandings. If you are harassed or feel unsafe, don’t hesitate to call for help.