A multiscale framework is developed for exploring tensile and compressive behaviors of single and multi-walled carbon nanotubes (CNTs). The multiscale approach is derived based on a molecular dynamic finite element method (MDFEM), in which new types of 2, 3 and 4-node MDFEM user elements are generated on the basis of force fields methodology. The bond stretch is modeled by 2-node MDFEM user element, and 3 and 4-node MDFEM user elements are used to describe bond bending and torsion with only bond angle and length needed. In this study, topological Stone–Wales (SW) defects with different positions and number are considered. Our results reveal that the ultimate tensile strengths are sensitive to CNT type, length and radius. Different type single-walled carbon nanotube (SWCNT) has different tensile failure configuration. The tensile failure configurations of multi-walled carbon nanotube (MWCNT) are individually difference to each other. The Stone–Wales defect not only largely reduces the ultimate tensile strength, but also significantly affects the tensile failure configuration. The local buckling and postbuckling configurations of SWCNTs are sensitive to CNT charity, location and number of SW defects. Besides, the local buckling and postbuckling responses of different types of MWCNTs are also examined in details.