The production cross section of a W boson in association with two b jets is measured using a sample of proton-proton collisions at sqrt(s) = 8 TeV collected by the CMS experiment at the CERN LHC. The data sample corresponds to an integrated luminosity of 19.8 inverse femtobarns. The W bosons are reconstructed via their leptonic decays, W to l nu, where l = mu or e. The fiducial region studied contains exactly one lepton with transverse momentum pt[l] > 30 GeV and pseudorapidity abs(eta[l]) < 2.1, with exactly two b jets with pt > 25 GeV and abs(eta) < 2.4 and no other jets with pt > 25 GeV and abs(eta) < 4.7. The cross section is measured to be sigma(pp to W (l nu)+ bb-bar) = 0.64 +/- 0.03 (stat) +/- 0.10 (syst) +/- 0.06 (theo) +/- 0.02 (lumi) pb, in agreement with standard model predictions.