Marcel Hesse, 20, committed the grisly crimes out of "bloodlust", dissatisfaction with his life, delusions of grandeur and "to satisfy his sadism and show off", prosecutors said during his trial.
The case shocked Germany when, almost a year ago, police learnt of the child's murder through images the killer had posted on the darknet -- hidden websites only accessible using encryption technology that are notoriously used to trade illegal drugs, weapons and child pornography.
Hesse had lured the boy from a nearby family home, in the western town of Herne, into his basement and stabbed him 52 times with a folding knife, then went on the run.
As authorities issued a public alert and staged a large-scale manhunt, Hesse hid out at the home of an acquaintance who had not yet heard of the crime.
When his 22-year-old host heard of the search the following morning and confronted Hesse, the killer murdered him too, stabbing him 68 times, the court was told.
Hesse stayed on and two days later set fire to the apartment, prosecutors told the court in the western city of Bochum.
He was arrested after three days on the run when he entered a restaurant in Herne and shouted "call the police, I'm wanted", Bild newspaper reported at the time.
Unemployed Hesse -- who was socially withdrawn, lived with his parents and spent a lot of time playing video games -- admitted to the crimes through his lawyer but did not speak in court.
Prosecutors told the court that Hesse had murdered "two completely innocent young people", had mocked them "in an inhumane way" by publishing images of their bodies and had terrified the local population.
The court dismissed the option of judging Hesse as a minor, which is possible for defendants up to age 21, and sentenced him to life in jail.
It judged that the crimes were of extraordinary severity, which means Hesse may be kept behind bars to protect society beyond Germany's usual maximum term of 15 years.