Context. Carbon chemistry plays a pivotal role in the interstellar medium (ISM) but even the synthesis of the simplest hydrocarbons and how they relate to polycyclic aromatic hydrocarbons (PAHs) and grains is not well understood. Aims. We study the spatial distribution and chemistry of small hydrocarbons in the Orion Bar photodissociation region (PDR), a prototypical environment in which to investigate molecular gas irradiated by strong UV fields. Methods. We used the IRAM 30 m telescope to carry out a millimetre line survey towards the Orion Bar edge, complemented with ∼2 × 2 maps of the C 2 H and c-C 3 H 2 emission. We analyse the excitation of the detected hydrocarbons and constrain the physical conditions of the emitting regions with non-LTE radiative transfer models. We compare the inferred column densities with updated gas-phase photochemical models including 13 CCH and C 13 CH isotopomer fractionation.Results. Approximately 40% of the lines in the survey arise from hydrocarbons (C 2 H, C 4 H, c-C 3 H 2 , c-C 3 H, C 13 CH, 13 CCH, l-C 3 H, and l-H 2 C 3 in decreasing order of abundance). We detect new lines from l-C 3 H + and improve its rotational spectroscopic constants. Anions or deuterated hydrocarbons are not detected, but we provide accurate upper limit abundances:Conclusions. Our models can reasonably match the observed column densities of most hydrocarbons (within factors of <3). Since the observed spatial distribution of the C 2 H and c-C 3 H 2 emission is similar but does not follow the PAH emission, we conclude that, in high UV-flux PDRs, photodestruction of PAHs is not a necessary requirement to explain the observed abundances of the smallest hydrocarbons. Instead, gas-phase endothermic reactions (or with barriers) between C + , radicals, and H 2 enhance the formation of simple hydrocarbons. Observations and models suggest that the [C 2 H]/[c-C 3 H 2 ] ratio (∼32 at the PDR edge) decreases with the UV field attenuation. The observed low cyclic-to-linear C 3 H column density ratio (≤3) is consistent with a high electron abundance (x e ) PDR environment. In fact, the poorly constrained x e gradient influences much of the hydrocarbon chemistry in the more UV-shielded gas. The inferred hot rotational temperatures for C 4 H and l-C 3 H + also suggest that radiative IR pumping affects their excitation. We propose that reactions of C 2 H isotopologues with 13 C + and H atoms can explain the observed [C 13 CH]/[ 13 CCH] = 1.4 ± 0.1 fractionation level.