Plant cyclic peptides (CPs) are a large group of small molecule metabolites found in a wide variety of plants, including traditional Chinese medicinal plants. However, the majority of plant CPs have not been studied for their biosynthetic mechanisms, including heterophyllin B (HB), which is one of the characteristic chemical components of Pseudostellaria heterophylla. Here, we screened the precursor gene (prePhHB) of HB in P. heterophylla and functionally identified its correctness in vivo and in vitro. First, we developed a new method to screen the precursors of HB from 16 candidate linear peptides. According to transcriptome sequencing data, we cloned the genes that encoded the HB precursor peptides and confirmed that the prePhHB-encoded precursor peptide could enzymatically synthesize HB. Next, we generated the transgenic tobacco that expressed prePhHB, and the results showed that HB was detected in transgenic tobacco. Moreover, we revealed that prePhHB gene expression is positively correlated with HB accumulation in P. heterophylla. Mutations in the prePhHB gene may influence the accumulation of HB in P. heterophylla. These results suggest that HB is ribosomally synthesized and posttranslationally modified peptide (RiPP) derived from the precursor gene prePhHB-encoded precursor peptide, and the core peptide sequence of HB is IFGGLPPP in P. heterophylla. This study developed a new idea for the rapid identification of Caryophyllaceae-type CP precursor peptides via RNA-sequencing data mining.