A search is performed for Higgs-boson-mediated flavor-changing neutral currents in the decays of top quarks. The search is based on proton-proton collision data corresponding to an integrated luminosity of 19.7 fb(-1) at a center-of-mass energy of 8 TeV collected with the CMS detector at the LHC. Events in which a top quark pair is produced with one top quark decaying into a charm or up quark and a Higgs boson (H), and the other top quark decaying into a bottom quark and a W boson are selected. The Higgs boson in these events is assumed to subsequently decay into either dibosons or difermions. No signi fi cant excess is observed above the expected standard model background, and an upper limit at the 95% con fi dence level is set on the branching fraction B (t -> Hc) of 0.40% and B (t -> Hu) of 0.55%, where the expected upper limits are 0.43% and 0.40%, respectively. These results correspond to upper limits on the square of the flavor-changing Higgs boson Yukawa couplings vertical bar lambda(H)(tc)vertical bar(2) < 6 . 9 x 10(-3) and vertical bar lambda(H)(tu)vertical bar(2) < 9 . 8 x 10(-3).