Vaccination is the most effective method to protect humans and animals from diseases. Anti-idiotype vaccines are safer due to their absence of pathogens. However, the commercial production of traditional anti-idiotype vaccines using monoclonal and polyclonal antibodies (mAb and pAb) is complex and has a high failure rate. The present study designed a novel, simple, low-cost strategy for developing anti-idiotype vaccines with nanobody technology. We used porcine circovirus type 2 (PCV2) as a viral model, which can result in serious economic loss in the pig industry. The neutralizing mAb-1E7 (Ab1) against PCV2 capsid protein (PCV2-Cap) was immunized in the camel. And 12 nanobodies against mAb-1E7 were screened. Among them, Nb61 (Ab2) targeted the idiotype epitope of mAb-1E7 and blocked mAb-1E7's binding to PCV2-Cap. Additionally, a high-dose Nb61 vaccination can also protect mice and pigs from PCV2 infection. Epitope mapping showed that mAb-1E7 recognized the 75NINDFL80 of PCV2-Cap and 101NYNDFLG107 of Nb61. Subsequently, the mAb-3G4 (Ab3) against Nb61 was produced and can neutralize PCV2 infection in the PK-15 cells. Structure analysis showed that the amino acids of mAb-1E7 and mAb-3G4 respective binding to PCV2-Cap and Nb61 were also similar on the amino acids sequences and spatial conformation. Collectively, our study first provided a strategy for producing nanobody-based anti-idiotype vaccines and identified that anti-idiotype nanobodies could mimic the antigen on amino acids and structures. Importantly, as more and more neutralization mAbs against different pathogens are prepared, anti-idiotype nanobody vaccines can be easily produced against the disease with our strategy, especially for dangerous pathogens.IMPORTANCEAnti-idiotype vaccines utilize idiotype-anti-idiotype network theory, eliminating the need for external antigens as vaccine candidates. Especially for dangerous pathogens, they were safer because they did not contact the live pathogenic microorganisms. However, developing anti-idiotype vaccines with traditional monoclonal and polyclonal antibodies is complex and has a high failure rate. We present a novel, universal, simple, low-cost strategy for producing anti-idiotype vaccines with nanobody technology. Using a neutralization antibody against PCV2-Cap, a nanobody (Ab2) was successfully produced and could mimic the neutralizing epitope of PCV2-Cap. The nanobody can induce protective immune responses against PCV2 infection in mice and pigs. It highlighted that the anti-idiotype vaccine using nanobody has a very good application in the future, especially for dangerous pathogens.