Stephan Letter, 28, nicknamed "the Angel of Death" by the German press, was found guilty of 12 counts of murder, 15 counts of manslaughter and one of death by request.
The court in Kempten, southern Germany, ruled that Letter's crimes were so serious that he would not qualify for release after 15 years, as is usual for prisoners serving life sentences in Germany.
Letter sat motionless as his sentence was read out.
Presiding judge Harry Rechner said Letter was of above-average intelligence with an IQ of 121, but had acted with "arrogance" towards his victims.
"None of the patients had reckoned with an attack on their lives," Rechner said.
Letter's lawyers said they would appeal the sentence.
Letter had claimed he acted out of compassion for his sick and elderly victims to spare them further suffering.
But prosecutor Peter Koch told the court that while this may have been the case with about half of the patients, Letter had killed many of the elderly patients in cold blood after paying little attention to their medical histories.
"The defendant killed as though he was on an assembly line," Koch said.
Family members of some of the victims have said that their relatives were on the road to recovery and looking forward to leaving the clinic and returning home, when they died mysteriously.
The killing spree took place between the start of 2003 and mid-2004 in a clinic in Sonthofen near Kempten.
The eldest victim was 95 and the youngest only 40 but most were in their seventies.
The deaths were not initially treated as suspicious, but Letter confessed to killing patients after being arrested for stealing medicine from the clinic.
Investigators then dug up the graves of 42 former patients to carry out autopsies, despite fierce resistance in some cases from their relatives.
Letter, a baby-faced, bespectacled man, retracted part of his confession when the trial began, saying he had been tricked by investigators.
Copyright AFP (Agence France-Presse), 2006