A revolutionary concept for achieving long-term medication release is the gastroretentive in situ gelling system. The goal of this research was to formulate and test a gastroretentive in situ gel for ketoprofen delivery to targeted site to increase the residence and delivery time. Ketoprofen gastroretentive in situ gels were synthesized using a cation-driven gelation approach using various combinations and concentrations of polymers such as gellan gum, sodium alginate, and hydroxypropyl methylcellulose (HPMC) K100M. Visual appearance, pH, viscosity, in vitro gelation, in vitro buoyancy, drug content, density measurement, gel strength measurement, water uptake, and in vitro drug release were all evaluated. The total floating time was more than 12 h, with a floating lag time of less than 2 min. The formulations showed pH ranging from 6.89 to 7.61 and drug content ranging from 82.01% to 95.53%. For 11 h, the percent cumulative drug release of formulations F5 and F14, which contained a greater concentration of polymer sodium alginate (1.5%) and a combination of gellan gum and HPMC K100M (0.175% and 0.2%), was 84.10% and 85.49%, respectively. In vitro dissolution experiments and stability investigations both revealed no significant changes in drug content. The findings revealed that the formulated in situ gels aided in extending gastric residence duration, allowing the drug to be released in the stomach.