Molecular knots represent one of the most extraordinary topological structures in biological polymers. Creating highly knotted nanostructures with well-defined and sophisticated geometries and topologies remains challenging. Here, we demonstrate a general strategy to design and construct highly knotted nucleic acid nanostructures, each weaved from a single-stranded DNA or RNA chain by hierarchical folding in a prescribed order. Sets of DNA and RNA knots of two- or three-dimensional shapes have been designed and constructed (ranging from 1700 to 7500 nucleotides), and they exhibit complex topological features, with high crossing numbers (from 9 up to 57). These single-stranded DNA/RNA knots can be replicated and amplified enzymatically in vitro and in vivo. Furthermore, this work establishes a general platform for constructing nucleic acid nanostructures with complex molecular topologies.