Using Wikipedia’s list of rail crashes and its UIC-sourced list of rail passenger-km by country, one can compare different countries’ mainline passenger rail accident fatality rates. The US turns out to be the least safe among the regions I’ve checked, even worse than India; much-maligned China comes out first.
I constructed the list below by averaging accident rates going back to 1991, to smooth out fluctuations coming from low-frequency, high-impact disasters. Crashes involving only freight trains are ignored, and pedestrians and car and bus passengers struck by passenger trains are included. Bombings are excluded, but sabotage incidents leading to accidents are included.
China: 876.22 billion passenger-km/year, 317 deaths over 20 years. This is one death per 55.3 billion passenger-km.
Japan: the UIC claims 253.55 billion passenger-km/year, which only includes JR companies. Figures including private railroads and excluding subways range from 360 to 395.9 billion passenger-km; I believe the higher number since it is slightly less dated. Over 20 years there have been 154 deaths, so this is one death per 51.4 billion passenger-km. Including subways would put Japan on a par with China.
EU-27: 386.24 billion passenger-km/year (presumably mainline only), 603 mainline deaths over 20 years. This does not include 155 deaths from a fire on a funicular. This is one death per 12.8 billion passenger-km, or 1 per 10.2 billion if the funicular fire is included. This varies a lot by country: the safest European countries, such as France and the Netherlands, are on a par with China and Japan, but the EU average is pulled down by Germany (due to Eschede) and the periphery.
South Korea: 31.3 billion passenger-km/year, 93 deaths over 20 years. This is one death per 6.7 billion passenger-km. Here the mainline-only rule is a problem because a) the Seoul subway is even more integrated with commuter rail than the Tokyo subway, and b) a subway fire in Daegu killed 198 people.
India: 838.03 billion passenger-km/year, 2,556 deaths over 20 years. This is one death per 6.6 billion passenger-km.
US: 27.26 billion passenger-km/year (both Amtrak and commuter rail), 159 deaths over 20 years. Note the rate is more than twice that of China per capita, let alone per rail passenger. This is one death per 3.4 billion passenger-km.
For comparison, the US road network has 33,000 accident deaths and 7.35 trillion passenger-km per year, which is one death per 220 million passenger-km.
On a closing note, China not only has the safest passenger trains, but also by far the busiest tracks. Freight density beats that of the US and Russia and passenger density beats that of any European country.