The HGm 51 was created from a construction locomotive that had been used in the construction of the Schwammendingen tram tunnel in Zurich. The locomotive was lengthened and widened by DFB. For this purpose, a new driver's cab was built and a cogwheel drive was installed. The converted locomotive could be used for the first time on the mountain line from Realp in the summer of 1987. Over the years, various further adaptations and improvements were made.