The three boys, aged 11, 13 and 14, were walking on the tracks when a regional train rounded a curve at 100 kph (60 mph) and hit them.
The train driver hit his emergency brakes but was unable to stop and all three boys were pronounced dead at the scene near the town of Germersheim on Tuesday afternoon, police said.
The 11- and 14-year-olds were brothers, and all three had been on their way home from a friend's house where they had gone after school.
The tracks were closed down through Wednesday morning
In another accident involving a train, a 53-year-old truck driver was killed near the northwestern town of Vechta when his vehicle was hit by a train as it drove over a crossing, police said.
Three passengers in the train suffered serious injuries and seven others were lightly injured in the Tuesday evening accident, police said.