Type XXI submarines were a class of German diesel–electric Elektroboot (German: "electric boat") submarines designed during the Second World War. One hundred and eighteen were completed, with four being combat-ready. During the war only two were put into active service and went on patrols, but these were not used in combat.
They were the first submarines designed to operate primarily submerged, rather than spending most of their time as surface ships that could submerge for brief periods as a means of escaping detection. They incorporated many batteries to increase the time they could spend submerged, to as much as several days, and they only needed to surface to periscope depth for recharging via a snorkel. The design included many general improvements as well: much greater underwater speed by an improved hull design, greatly improved diving times, power-assisted torpedo reloading and greatly improved crew accommodations. However, the design was also flawed in many ways, with the submarines being mechanically unreliable and vulnerable to combat damage. The Type XXI submarines were also rushed into production before design work was complete, and the inexperienced facilities which constructed the boats were unable to meet necessary quality standards.
After the war, several navies obtained Type XXIs and operated them for decades in various roles, while large navies introduced new submarine designs based on them. These include the Soviet , American , British Porpoise, and Swedish classes, all based on the Type XXI design to some extent.
The main features of the Type XXI were the hydrodynamically streamlined hull and conning tower and the large number of battery cells, roughly triple that of the German Type VII submarine. This gave these boats great underwater range and dramatically reduced the time spent on or near the surface. They could travel submerged at about for about 75 hours before recharging batteries, which took less than five hours using the snorkel due to the new super-charged diesel engines.