The D58 class was a class of steam locomotives operated by the New South Wales Government Railways in Australia. They were built with the 4-8-2 wheel arrangement.
In 1943, approval was given for the N.S.W.G.R. Workshops to build 25 locomotives and tenders to a design modified from the D57-class. The main alterations were the use of a rack and pinion valve gear in lieu of the Gresley 2:1 conjugated vale gear for the middle cylinder and the use of smaller cylinders to enable the locomotives to run to Newcastle, a route which had a tighter loading gauge. They also used a Woodard divided drive of twin coupling rods between the second and third driving wheels. A valance was fitted over the valve gear on the front platform. Eveleigh Workshops built 11 locomotives and Cardiff Workshops built two. 5801 was placed in traffic in March, 1950. Following the building of 13 locomotives, construction was suspended owing to lack of funds, dieselisation and also, to a degree, dissatisfaction with their performance in traffic. Work was never resumed on the remainder of the order.
Whilst the derived rack and pinion valve gear appeared far superior in theory, in practice it required more maintenance and lubrication. The smaller diameter cylinders demanded a later cut-off and used more steam, thus making the locomotives uneconomical in the use of coal and water when compared with the 57-class. Despite the design being made to enable use on the Main Northern line from Sydney to Broadmeadow, very few journeys were ever made. After a very short service life, the entire class had been withdrawn by July, 1957 and were all cut up by March, 1964. Some parts were recovered and used on 57-class locomotives. There are no surviving examples, however the tender of 5808 lies near Canberra Station. Many 57 and 58 class tenders were used as water tankers around NSW. One is at the DSR&M. Some small parts are with the NSWRHC.