The type 21 was one of the most numerous steam locomotive classes on the Norwegian State Railway (NSB) system. A total of 42 examples were constructed which were at the time of construction divided into three subtypes, the type 21a, 21b and 21c.
The 21a locomotive was an evolution of the type 15c locomotive. The first of these type 15 locomotives were built in the Scotland by the firm of Dubs & Co of Glasgow and bore a striking resemblance to the goods locomotives designed by David Jones of the Highland Railway.

The type 21 locomotives were delivered new to the Voss line (Bergen-Voss). Because of the Voss lines many sharp curves, especially the harbour lines in Bergen, the fixed wheelbase was reduced from 3810mm on the type 15c to 3352mm on the type 21a, and the boiler raised by 13.4 cm so that the firebox would fit between the two rear driving axles where the wheelbase had been shortened . These design changes from the 15c type resulted in the engines being given their own designations as type 21a. Between 1904 and 1906 a total of 10 locomotives of the new class were ordered and delivered from the two firms; Thune Mechanical Workshop in Oslo, and Hamar Foundry . These ten engines were two-cylinder compound locomotives with slide valves and no superheaters. The first five locomotives Nos. 174-178 were commissioned in 1902 from the locomotive firm Thune of Oslo and these were delivered in July 1904. They were transported in pieces by boat from Oslo to Bergen where they were assembled. On delivery the engines entered service as mixed traffic locomotives hauling both freight and passenger trains.

The earlier type 15 (and type 11 before them) were intended as a freight only locomotives but they also proved well suited for local passenger workings. The type 21 locomotive must have proved successful for the traffic on the Voss line as between 1904 and 1905, a further five such locomotive were ordered for the line which were delivered in 1905 and 1906.

In the meantime several other railways in Norway were rebuilt from narrow gauge to standard gauge. Several of these re-gauged lines required new locomotives and between 1909 and 1910 a total of 10 further type 21 locomotives were delivered from the same firms in Oslo and Hamar. These ten locomotives entered service at the Solør line (between Kongsvinger and Elverum), the Otta line (between Hamar and Otta) and the Randsfjord line (Drammen -Hønefoss)
In 1909 the firm Hamar Foundry delivered a further two locomotives to the Randsfjord-line , however this time they were not built as compound engines, but as a conventional two cylinder locomotives with piston valves, and superheaters (the first steam locomotives in Norway to be so equipped). These locomotives were classified as type 21b and were followed by a further 12 similar engines delivered from Hamar Foundry and Thune during 1908 and 1919. These entered service on the Østfold line and the Kongsvinger line (Lillestrøm- Kongsvinger).
To improve on fuel economy several experiments were tried in the early part of the 20th century with boiler feed water heaters. On a traditional locomotive the boiler would be filled with water from a tank via the use of steam powered injectors. This water is however colder than the water inside the boiler. As this water is fed into the boiler it cools the boiler water and leads to a reduction in pressure. By pre-heating the feed water this loss of pressure can be minimised leading to better overall fuel consumption.
The Knorr Feed Water Heater pre-heated the water as it passed through a reservoir that could be filled with steam from the boiler. This was then pumped into the boiler by a small steam pump.
In 1918 a further batch of eight type 21 locomotives were ordered from Nydquist-Holm in Sweden. This batch of locomotives, numbered 370 to 377 were fitted with Knorr Feed Water Heaters and were delivered to the NSB in 1919. These engines weighed some 2 tons more than the standard type 21 locomotives (due to the feed water gear) and so were designated as type 21c. However the feed water system was quite complicated and required regular maintenance from trained staff and the gains made from the better fuel efficiency were lost in labor and maintenance costs resulting in the removal of the feed water gear.

Later rebuilding of several of the older locomotives of the class 21a and 21b led to locomotives with several differences and these were given the classification 21d and 21e. Six locomotives of the old 21a class were rebuilt between 1923 and 1925.These were rebuilt with superheated boilers, but their compound machinery cylinders and slide valves were retained and they recieved the classification 21d .
The class 21d were less than satisfactory, due to the combination of superheated steam and slide valves. They were all rebuild in 1929 as conventional two cylindered engines with outside admission piston valves and were classified as type 21e. In later years several of the type 21b locomotives were also rebuilt as type 21e engines.
The compound locomotives of the class 21 were the first locomotives to be withdrawn from service starting in 1929 with the last being withdrawn in 1955. The engines with superheaters remained in service much longer. They were very economical and proved well suited to their branchline environment. In 1969 there were still seven class 21 engines in operation on the NSB.
The last type 21 locomotives in regular service were on the 92 km long Numedals branchline. A weekly freight train operated with a class 21 until May 1970, and a regular train ballast train lasted until that autumn. These trains were the last regularly steam hauled trains on the NSB network making the class 21 the last steam loco type used on the NSB.

Due to the large number of class 21 and their long life career in service by the NSB a total of five locomotives have been preserved:
- Type 21e No.207. After withdrawal on the 22nd June 1971 this engine was allocated to the Norwegian Railway Museum, but was left with the Norwegian Railway Association. The locomotive is not operational and stored inside one of the loco sheds on the heritage Krøderen-line.
- Type 21b No.225 Originally sold for scrap in 1971 this engine was bought by members of the Norwegian Railway Association. After many years of restoration work to bring the locomotive back to its original appearance it was returned to traffic in 1982 and used until 1995 on the Krøderen heritage railway. The locomotive is currently again under overhaul.
- Type 21b No.252. This locomotive was used on the Norwegian Railway Associations first steam hauled excursion train in October 1970. The locomotive was then handed over to the Norwegian Technical Museum, but the Norwegian Railway Association took custody in 1973 and used it for various excursions until 1977. A new boiler was built in Meinigen, Germany and the locomotive is now currently dismantled as part of a long-term overhaul.
- Type 21c No.376 Currently preserved in operational condition on the Kent and East Sussex Railway. For more info on No.376 please click HERE.
- Type 21c No.377. Bought by a private individual and moved to the UK this locomotive was put into operation on the Great Central Railway in 1973. Later purchased in 1986 by the Bressingham Steam and Gardens in Norfolk it is now on static display.