We use optical data from the Palomar Transient Factory (PTF) and the Catalina Real-Time Transient Survey (CRTS) to study the variability of {gamma}-ray-detected and non-detected objects in a large population of active galactic nuclei selected from the Candidate Gamma-Ray Blazar Survey and Fermi Gamma-Ray Space Telescope catalogues. Our samples include 714 sources with PTF data and 1244 sources with CRTS data. We calculate the intrinsic modulation index to quantify the optical variability amplitude in these samples.