|The train was travelling at about 20 mph (32 km/h) when the incident took place|
An investigation has been launched following the near miss on the South Devon Railway heritage line.
The child's mother opened the cubicle door as they travelled between Staverton and Buckfastleigh to find the floor had been completely removed, according to the Rail Accident Investigation Branch (RAIB).
She managed to catch hold of him in time to stop him falling on to the exposed track.
The little boy suffered minor bruising and both were left in shock, investigators said.
In a photograph released by the RAIB, greenery is clearly visible through the floor of the cubicle.
The train was travelling at about 20 mph (32 km/h) when the incident took place.
The RAIB said engineers had carried out repairs to the train's braking system which required the toilet floor to be dismantled.
It had not been replaced but a notice had been put on the door and staff had attempted to secure it.
However, the safety measures "had not been effective", the RAIB said.
An independent investigation has been opened into the incident, which happened on 25 June.