A search for the decays B 0 s → e + e − and B 0 → e + e − is performed using data collected with the LHCb experiment in proton-proton collisions at center-of-mass energies of 7, 8, and 13 TeV, corresponding to integrated luminosities of 1, 2, and 2 fb − 1 , respectively. No signal is observed. Assuming no contribution from B 0 → e + e − decays, an upper limit on the branching fraction B ( B 0 s → e + e − ) < 9.4 ( 11.2 ) × 10 − 9 is obtained at 90(95)% confidence level. If no B 0 s → e + e − contribution is assumed, a limit of B ( B 0 → e + e − ) < 2.5 ( 3.0 ) × 10 − 9 is determined at 90(95)% confidence level. These upper limits are more than one order of magnitude lower than the previous values.