Rigid particles suspended in viscoelastic fluids under shear can align in string-like structures in the flow direction. Although this phenomenon was first reported almost four decades ago by Michele et al. [J. Michele, R. Pätzold, R. Donis, Alignment and aggregation effects in suspensions of spheres in non-Newtonian media, Rheologica Acta 16 (1977) 317–321.], the exact mechanism of particle alignment is not completely understood. Initially, it was believed that normal stress differences are responsible for the alignment of particles, but recent experimental work by van Loon et al. [S. Van Loon, J. Fransaer, C. Clasen, J. Vermant, String formation in sheared suspensions in rheologically complex media: The essential role of shear thinning, Journal of Rheology 58(1) (2014) 237–254.] showed particle alignment in a shear-thinning fluid without significant normal stress differences.To unravel the phenomenon of particle alignment, we present for the first time 3D direct numerical simulations of the alignment of two and three rigid, non-Brownian particles in a viscoelastic shear flow, with the shear rate denoted by γ˙. The equations are solved on moving, boundary-fitted meshes, which are locally refined to accurately describe the polymer stresses around and in between the particles. A small minimal gap size between the particles is introduced. The Giesekus model, with a relaxation time λ, is used for the viscoelastic fluid, and the effect of the Weissenberg number Wi=λγ˙, shear thinning parameter α and ratio between the solvent viscosity and zero-shear viscosity β is investigated.The numerical method allows for the detailed investigation of particles interacting in viscoelastic flows. Alignment of two and three particles is observed in the simulations. Morphology plots were created for various values of α, β and Wi. Alignment is mainly governed by the value of the elasticity parameter S, defined as half of the ratio between the first normal stress difference and shear stress of the suspending fluid. Alignment appears to occur above a critical value of S, which decreases with increasing α, thus shear thinning promotes alignment. Furthermore, three particles align at lower S than two particles. Finally, simulations were performed in a shear-thinning Carreau fluid, where we never observed alignment of the particles. These results lead us to the conclusion that the presence of normal stress differences is essential for particle alignment to occur, although it is strongly promoted by shear thinning.