  The aim of this paper is to study the formation of anisotropic compact stars
in modified $f(R)$ theory of gravity, which is the generalization of the
Einstein's gravity. To this end, we have used the solution of Krori and Barua
to the anisotropic distribution of matter in $f(R)$ gravity. Further, we have
matched the interior solution with the exterior solution to determine the
constants of Krori and Barua solution. Finally the constant have been
determined by using the data of compact compact stars like 4$U1820-30, Her X-1,
SAX J 1808-3658$. Using the evaluated form of the solutions, we have discussed
the regularity of matter components at the center as well as on the boundary,
energy conditions, anisotropy, stability analysis and mass-radius relation of
the compact stars 4$U1820-30$, $Her X-1$, $SAX J 1808-3658.$
