NSW's fleet of XPT trains have "well and truly served their purpose" after more than three decades of service and will begin to be replaced from 2023.

The Regional Transport Minister Paul Toole made the comments as he expressed his sympathies to family and friends of the victims of a fatal derailment of an XPT train carrying 153 passengers from Sydney on Thursday night at Wallan, north of Melbourne. The driver, a 54-year-old man from the ACT, and the train's pilot, a 49-year-old from Castlemaine who identified as a man, were killed.

While he declined to speculate on the cause of the derailment, Mr Toole said the state government would be replacing the XPTs as part of an upgrade of the regional fleet from 2023.

"Some of these trains are more than 38 years old, so they've well and truly served their purpose over that time into regional communities," he said.