Programmed self-assembly of nucleic acids is a powerful approach for nano-constructions. The assembled nanostructures have been explored for various applications. However, nucleic acid assembly often requires chemical or in vitro enzymatical synthesis of DNA or RNA, which is not a cost-effective production method on a large scale. In addition, the difficulty of cellular delivery limits the in vivo applications. Herein we report a strategy that mimics protein production. Gene-encoded DNA duplexes are transcribed into single-stranded RNAs, which self-fold into well-defined RNA nanostructures in the same way as polypeptide chains fold into proteins. The resulting nanostructure contains only one component RNA molecule. This approach allows both in vitro and in vivo production of RNA nanostructures. In vivo synthesized RNA strands can fold into designed nanostructures inside cells. This work not only suggests a way to synthesize RNA nanostructures on a large scale and at a low cost but also facilitates the in vivo applications.