The accumulation of amyloid-beta (Aβ) oligomers is recognized as a potential culprit in Alzheimer's disease (AD). Experimental studies show that melatonin, a hormone that mainly regulates circadian rhythm and sleep, can interact with Aβ peptides and disrupt the formation of oligomers. However, how melatonin inhibits the oligomerization of soluble Aβ is unclear. Here, by computational simulations, we investigate the effect of different levels of melatonin on the conformation of the Aβ 42 dimer. We find that the conformation of the Aβ 42 dimer is dependent on melatonin levels. When melatonin is absent, the dimer mainly forms a parallel β-sheet in the CHC region.When one melatonin molecule is present, the overall conformation of the dimer does not change much, but the N-terminal of the dimer tends to adopt antiparallel β-sheets. When two melatoinin molecules are present, the Aβ 42 dimer exhibits significant structural change, especially in its central region, resulting in a more compact conformation, and forms parallel β-sheets in the C-terminal. This conformational difference induced by different levels of melatoinin can shed light on the protective role of melatonin.