Molecular electronics is often limited by the lack of a simple method to fabricate nanoelectrodes with controlled gap size. This is partly attributed to the lack of a real time characterization in the fabrication. Here, we report a new method based on an electron induced deposition process operated in scanning electron microscopy that realizes in situ and real time characterization in the nanoelectrode fabrication; thus the gap size can be controlled easily and precisely. It is a clean and nondestructive process for carbon nanotube (CNT) electrodes. The mechanism is detailed. The nanoelectrodes have a pi-conjugated surface due to the deposition of sp(2)-rich amorphous carbon. As an application, DNA molecules are assembled between the CNT electrodes by pi-stacking interaction for current-voltage measurement. Our result provides a feasible route to prepare nanoelectrodes with controlled gap size, and it will be valuable for current efforts in molecular electronics and nanoelectronics.