A measurement of the inclusive ZZ production cross section and constraints on anomalous triple gauge couplings in proton-proton collisions at √s=8TeV are presented. The analysis is based on a data sample, corresponding to an integrated luminosity of 19.6/fb, collected with the CMS experiment at the LHC. The measurements are performed in the leptonic decay modes ZZ→lll′l′, where l=e,μ and l′=e,μ,τ. The measured total cross section σ(pp→ZZ)=7.7±0.5(stat)+0.5−0.4(syst)±0.4(theo)±0.2(lumi)pb, for both Z bosons produced in the mass range 60<mZ<120GeV, is consistent with standard model predictions. Differential cross sections, in phase space pT(μ)>5GeV, pT(e)>7GeV, |η(μ)|<2.4 , |η(e)|<2.5 and the 60--120 \text{GeV} mass requirement, are measured and well described by the theoretical predictions. The invariant mass distribution of the four-lepton system is used to set limits on anomalous ZZZ and ZZγ couplings at the 95\% confidence level, −0.004<f4Z<0.004, −0.004<f5Z<0.004, −0.005<f4γ<0.005, and −0.005<f5γ<0.005.