Purpose Drawing on the generativity framework, this study aims to investigate the relationship between the Dark Triad personalities (Machiavellianism, narcissism, and psychopathy) and knowledge hiding. This study also identifies the mediating role of generativity motivation and the moderating role of focus on opportunities. Design/methodology/approach Using a convenience sample, a two-wave time-lagged study collected survey responses from 498 employees from manufacturing industries in China, and the data was analyzed using hierarchal regression and bootstrapping methods. Findings This study found that Machiavellianism and psychopathy are both positively related to generativity motivation. The generativity motivation plays a mediating role in the paths of Machiavellianism and psychopathy on knowledge hiding, and a focus on opportunities positively moderates the direct and indirect effect of Machiavellianism and psychopathy on knowledge hiding. Originality/value Based on the generativity framework, we find a new underlying mechanism between the Dark Triad personalities and knowledge hiding, thereby further enriching the literature in relation to their influence over knowledge management. Moreover, it also finds that a focus on opportunities can weaken the negative relationships between the Dark Triad personalities and knowledge hiding.