German submarine U-642 was a Type VIIC U-boat built for Nazi Germany's Kriegsmarine for service during World War II. She was laid down on 19 November 1941 by Blohm & Voss, Hamburg as yard number 618, launched on 6 August 1942 and commissioned on 1 October 1942 under Kapitänleutnant Herbert Brünning.
German Type VIIC submarines were preceded by the shorter Type VIIB submarines. U-642 had a displacement of when at the surface and while submerged. She had a total length of , a pressure hull length of , a beam of , a height of , and a draught of . The submarine was powered by two Germaniawerft F46 four-stroke, six-cylinder supercharged diesel engines producing a total of for use while surfaced, two Brown, Boveri & Cie GG UB 720/8 double-acting electric motors producing a total of for use while submerged. She had two shafts and two propellers. The boat was capable of operating at depths of up to .
The submarine had a maximum surface speed of and a maximum submerged speed of . When submerged, the boat could operate for at ; when surfaced, she could travel at . U-642 was fitted with five torpedo tubes (four fitted at the bow and one at the stern), fourteen torpedoes, one SK C/35 naval gun, 220 rounds, and one twin C/30 anti-aircraft gun. The boat had a complement of between forty-four and sixty.
The boat's career began with training at 5th U-boat Flotilla on 1 October 1942, followed by active service on 1 March 1943 as part of the 6th Flotilla. She transferred for operations in the Mediterranean on 1 December 1943 to serve with 29th Flotilla for the remainder of her service.
In 4 patrols she sank 1 merchant ship, for a total of .
U-642 took part in nine wolfpacks, namely:
U-642 was sunk on 5 July 1944 in the Mediterranean at Military port of Toulon in position , by a US air raid.