We present the first cosmological constraints derived from the analysis of the void size function. This work relies on the final Baryon Oscillation Spectroscopic Survey (BOSS) Data Release 12 (DR12) data set, a large spectroscopic galaxy catalog, ideal for the identification of cosmic voids. We extract a sample of voids from the distribution of galaxies, and we apply a cleaning procedure aimed at reaching high levels of purity and completeness. We model the void size function by means of an extension of the popular volume-conserving model, based on two additional nuisance parameters. Relying on mock catalogs specifically designed to reproduce the BOSS DR12 galaxy sample, we calibrate the extended size function model parameters and validate the methodology. We then apply a Bayesian analysis to constrain the Lambda cold dark matter (ΛCDM) model and one of its simplest extensions, featuring a constant dark energy equation of state parameter, w. Following a conservative approach, we put constraints on the total matter density parameter and the amplitude of density fluctuations, finding Ωm = 0.29 ± 0.06 and
σ
8
=
0.79
−
0.08
+
0.09
. Testing the alternative scenario, we derive w = −1.1 ± 0.2, in agreement with the ΛCDM model. These results are independent and complementary to those derived from standard cosmological probes, opening up new ways to identify the origin of potential tensions in the current cosmological paradigm.