The final months of the war were spent in the South China Sea attacking Japanese merchantmen, and patrolling the Lombok Strait. In February 1945, "Zwaardvisch" was attacked and damaged by a Japanese aircraft and had to return to Fremantle the following month for repairs. Once these were complete, she returned to the Java Sea under the command of Lieutenant Jan van Dapperen, where she made further attacks on Japanese merchantmen throughout April and May before returning to Fremantle to repair faulty communications and weapons systems. Following the surrender of Germany in early May, the submarine returned to Britain to undertake further repairs in Dundee before transferring to Rotterdam in August 1945.