Huntington disease is a neurodegenerative disorder caused by the expansion of polyglutamine (polyQ) at the N-terminal of the huntingtin exon 1 protein. The detailed structure and the mechanism behind this aggregation remain unclear and it is assumed that the polyQ undergoes a conformational transition to the β-sheet structure when it aggregates. Investigating the misfolding of polyQ facilitates the determination of the molecular mechanism of aggregation and can potentially help in developing a novel approach to inhibit polyQ aggregation. Moreover, the flanking sequences of the polyQ region play a vital role in structural changes and the aggregation mechanism. We performed all-atom molecular dynamics simulations to gain structural insights into the aggregation mechanism using eight different models with glutamine repeat lengths Q27 , Q27 P11 , Q34 , Q35 , Q36 , Q40 , Q50 , and Q50 P11 . In the models without flanking polyPs, we noticed that the transformation of a random coil to β-sheet occurs when the number of Q increases. We also found that the flanking polyPs prevent aggregation by decreasing the probability of forming a β-sheet structure. When polyQ length increases, the 17 N-terminal flanking residues are more likely to adopt a β-sheet conformation from α-helix and coil. From our simulations, we suggest that at least 34 glutamines are required for initiating aggregation and 40 residues length is critical for the aggregation of huntingtin exon 1 protein for disease onset. This study provides structural insights into misfolding and the role of flanking sequences in huntingtin aggregation which will further help in developing therapeutic strategies for Huntington's disease.