Chocolate has been shown to contain a number of different stimulants and chemicals (see below) that may trigger the release of endogenous endorphins ("endogenous morphine"). However, the antidepressant effects of chocolate seem to have been exaggerated in popular culture. A review article by Parker et al.1 notes that the concentrations of certain psychoactive ingredients are too low to have a significant effect. The paper concludes:
For most people chocolate invokes anticipatory and consummatory pleasure, and is therefore an indulgence. When taken in response to a dysphoric state as an ‘emotional eating’ strategy it may provide some transient ‘comforting’ role but it is more likely to
prolong rather than abort the dysphoric mood. It is not, as some would claim, an antidepressant.
So, while chocolate may provide some mild and transient stimulatory effect, it does not appear to be an effective antidepressant.
However, the known presence of psychoactive chemicals in chocolate (albeit in small quantities) does provide some scientific basis for Rowling's use of it as a medical and psychological treatment. A speculative in-universe explanation could be that chocolate simply has additional magical properties that make its inherent chemicals more effective, or perhaps these chemicals are more effective on the magically inclined even at lower concentrations.
- Mood state effects of chocolate. Parker G, Parker I, Brotchie H. J Affect Disord. 2006 Jun;92(2-3):149-59.
Chemicals in chocolate: