The boy was playing with his little brother at the home in Lichterfelde, Berlin, when he found the ultimate hiding place.
Unfortunately, the door to the unused safe closed on the boy, locking him in.
His whereabouts were eventually uncovered - but his grandfather was the only person who knew the entry code, and he was away.
With no other option, the family called for help from the fire brigade.
It took three hours of testing family birth dates in the hope of uncovering the secret entry code, while oxygen was pumped into the safe through a tiny crack as a precaution.
Just as a specialist team was about to start breaking the safe open, they entered the correct six-digit code.
More from Berlin
Love Zoo: Will sex cure panda's habit of walking backwards?
From Nice to Barcelona: A year of vehicle attacks
Bag of gold bars and cash worth £30k found under tree in Berlin
Changing of the Guard changed after Berlin Christmas market attack
Berlin Christmas market killer Anis Amri used 14 aliases
Berlin attack: CCTV shows Anis Amri in Belgium two days after massacre
Firefighters say the child remained calm throughout the ordeal and was shocked but unharmed.
Berlin firefighter Thomas Kirstein said it was happy ending and super early Christmas present.