Formation of porous n-silicon by photoelectrochemical etching which corresponds to a controlled corrosion under light and anodic polarization in HF is described here. PEC etching induces the simultaneous formation of two different types of porous silicon layer near the surface. The top layer which can easily be dissolved in KOH consists most probably of porous silicon with pore diameters in the nanometer range (''nanoporous silicon''). The nanoporous layer covers a second layer which exhibits macropores (pore diameters in the micron range) whose geometrical form for highly doped Si depends on the crystallographic orientation. In order to get some insight into the chemical nature of the porous silicon, X-ray photoelectron spectroscopy, secondary ion mass spectroscopy and infrared spectroscopy were used. After PEC etching the surface Si-H bonds initially present after chemical etching in HF become oxidized.