This paper deals with mathematical modeling and study of nonlinear switching in optical fiber Bragg gratings (FBG) by a transfer matrix method. Critical parameters contributing to high performance nonlinear fiber Bragg grating were studied. The transmission spectrum centered at 1550 nm was analyzed with varying number of layers and refractiveindices. The study showed that by proper modification in grating length of the FBG, we were able to optimize transmission spectrum for required application. The nonlinear behavior of FBGs can be further applied in optical switching applications (all-optical logic gates).