Infrared and (sub-)mm observations of disks around T Tauri and Herbig Ae/Be stars point to a chemical differentiation between both types of disks, with a lower detection rate of molecules in disks around hotter stars. To investigate the potential underlying causes we perform a comparative study of the chemistry of T Tauri and Herbig Ae/Be disks, using a model that pays special attention to photochemistry. The warmer disk temperatures and higher ultraviolet flux of Herbig stars compared to T Tauri stars induce some differences in the disk chemistry. In the hot inner regions, H2O, and simple organic molecules like C2H2, HCN, and CH4 are predicted to be very abundant in T Tauri disks and even more in Herbig Ae/Be disks, in contrast with infrared observations that find a much lower detection rate of water and simple organics toward disks around hotter stars. In the outer regions, the model indicates that the molecules typically observed in disks, like HCN, CN, C2H, H2CO, CS, SO, and HCO+, do not have drastic abundance differences between T Tauri and Herbig Ae disks. Some species produced under the action of photochemistry, like C2H and CN, are predicted to have slightly lower abundances around Herbig Ae stars due to a narrowing of the photochemically active layer. Observations indeed suggest that these radicals are somewhat less abundant in Herbig Ae disks, although in any case the inferred abundance differences are small, of a factor of a few at most. A clear chemical differentiation between both types of disks concerns ices, which are expected to be more abundant in Herbig Ae disks. The global chemical behavior of T Tauri and Herbig Ae/Be disks is quite similar. The main differences are driven by the warmer temperatures of the latter, which result in a larger reservoir or water and simple organics in the inner regions and a lower mass of ices in the outer disk.