CDI can be prepared straightforwardly by the reaction of phosgene with four equivalents of imidazole under anhydrous conditions.  Removal of the side product, imidazolium chloride, and solvent results in the crystalline product in ~90% yield.
:4 CHN  +  C(O)Cl  →   (CHN)CO  +  2 [CHNH]Cl
In this conversion, the imidazole serves both as the nucleophile and the base.  An alternative precursor 1-(trimethylsilyl)imidazole requires more preparative effort with the advantage that the coproduct trimethylsilyl chloride is volatile.
CDI hydrolyzes readily to give back imidazole:
:(CHN)CO  +  HO  →   2 CHN  +  CO
The purity of CDI can be determined by the amount of CO that is formed upon hydrolysis.