This study is focused on the effects of pH on the production of volatile fatty acids (VFAs) and their distribution through the acidogenic fermentation of source-sorted organic fraction of municipal solid waste (OFMSW) from a mechanical-biological treatment (MBT) plant, and food waste (FW) from a university canteen. In semi-continuous lab-scale digesters using OFMSW at a hydraulic retention time (HRT) of 3.5 days under acidic conditions (pH 6.0), the VFA concentration in the effluent increased to 9.8–11.5 g L−1 (VS content of the feedstock between 4.2 and 5.2% w/w), while its individual VFA profiling was similar to the influent which was already pre-fermented (namely, C2 35–41%, C3 18–22%, C4 17–21%, and C5 9–12%). When working with the same conditions but using FW as feedstock, an effluent with a VFA concentration up to 11.5 g VFA L−1 (FW with a VS content of 5.5% w/w) and a stable distribution of C2 and C4 acids (up to 60.3% and 12.9%, respectively) but with very low quantities of C3 and C5 acids (lower than 1.8 and 2.7%, respectively) was obtained. Anaerobic batch tests using FW revealed that alkaline pH near 9 could lead to higher VFA production with high acetic acid content when compared to pH 6. In the semi-continuous fermenters working at alkaline conditions (pH 9.5–10) using OFMSW and FW, an enhanced solubilization of organic matter was registered with respect to the fermenters working under acidic conditions. This fact was not reflected in a higher VFA production when using OFMSW as feedstock, probably due to free ammonia inhibition, since OFMSW was mixed in the MBT plant with supernatant from anaerobic digestion of this biowaste. However, when using FW, alkaline conditions lead to an enhanced VFA production with respect to the reactor working under acidic conditions, being acetic acid the predominant product, which represented up to 91% of the VFA spectrum obtained.Electronic supplementary materialThe online version of this article (10.1007/s11356-019-05394-6) contains supplementary material, which is available to authorized users.