We studied the abundance of HCN, H13CN, and HN13C in a sample of prestellar cores, in order to search for species associated with high density gas. We used the IRAM 30m radiotelescope to observe along the major and the minor axes of L1498, L1521E, and TMC 2, three cores chosen on the basis of their CO depletion properties. We mapped the J=1-0 transition of HCN, H13CN, and HN13C towards the source sample plus the J=1-0 transition of N2H+ and the J=2-1 transition of C18O in TMC 2. We used two different radiative transfer codes, making use of recent collisional rate calculations, in order to determine more accurately the excitation temperature, leading to a more exact evaluation of the column densities and abundances. We find that the optical depths of both H13CN(1-0) and HN13C(1-0) are non-negligible, allowing us to estimate excitation temperatures for these transitions in many positions in the three sources. The observed excitation temperatures are consistent with recent computations of the collisional rates for these species and they correlate with hydrogen column density inferred from dust emission. We conclude that HCN and HNC are relatively abundant in the high density zone, n(H2) about 10^5 cm-3, where CO is depleted. The relative abundance [HNC]/[HCN] differs from unity by at most 30 per cent consistent with chemical expectations. The three hyperfine satellites of HCN(1-0) are optically thick in the regions mapped, but the profiles become increasingly skewed to the blue (L1498 and TMC 2) or red (L1521E) with increasing optical depth suggesting absorption by foreground layers.