Prezymyslaw Kaluzny admitted stripping naked at the Toys R Us store before grabbing the young boy and hitting his 67-year-old grandmother on the head.
The 41-year-old pleaded guilty to a series of charges including public indecency, assault and abduction.
He was detained in a secure hospital ahead of a review hearing in December.
Dundee Sheriff Court heard the Polish national has a lengthy criminal history, including previous convictions for robbery, hostage taking and burglary.
Prosecutors said the store CCTV of the incident at the Kingsway toy shop was "extremely distressing and sensitive".
Kaluzny entered the store carrying a baseball bat on 5 April this year before stripping naked. He walked down an aisle shouting and struggling with customers, placing them in a state of fear and alarm.
He then grabbed a six-year-old boy by the arm and dragged him along the ground, before picking him up in a bid to take him from the store against his will.
When the boy's 67-year-old grandmother tried to intervene, Kaluzny hit her on the head with a cricket bat, leaving her injured.
Although he was eventually subdued by other customers and police, Kaluzny then managed to snap the metal bar and plastic casing of a pair of handcuffs while in a police car.
His defence solicitor Nicola Brown said he had written "what is a letter of apology, in essence", which is to be translated for the court.
Sheriff Lorna Drummond imposed an interim compulsion order, meaning Kaluzny will be detained in a secure hospital to undergo treatment for a mental disorder ahead of a review hearing in December.
A man has admitted abducting a six-year-old boy and hitting a woman with a cricket bat during a naked rampage at a Dundee toy shop on Easter Sunday.