Background: Our goal was to prepare and evaluate topical ophthalmic formulations containing optimized celecoxib-loaded bioadhesive cationic chitosan or anionic alginate nanoparticles for sustained release of celecoxib. Methods: Nanoparticles were prepared using a spontaneous emulsification solvent diffusion method. Different concentrations of polymers, emulsifier and stabilizers were used to optimize our formulations. The formulation that gave the lowest particle size and polydispersity index and the highest zeta potential was selected and subjected to further studies. The optimized celecoxibloaded NPs were characterized with regard to their particle size, polydispersity index, zeta potential, morphology and drug content. Celecoxib-loaded NPs were incorporated in topical ophthalmic dosage forms including eye drops, temperature-triggered in situ gelling system and preformed gel. All formulations were then characterized regarding their pH, viscosity, uniformity of drug content, in vitro release study and in vitro cytotoxicity. Results: Results of the optimization studies of both celecoxib-loaded chitosan and alginate nanoparticles respectively, are: particle size of 113.33 ± 4.08 nm and 154.67 ± 5.06 nm; zeta potential of +36.92 ± 3.38 mV and -36.5 ± 4.7 mV; and encapsulation efficiencies of 89.88 ± 4.17% and 75.38 ± 2.98%. Transmission electron microscopic analysis revealed that all nanoparticles have distinct spherical shapes comprising of a solid dense core covered with evenly distributed coat. oreover, all formulations possessed pH and viscosity values that are compatible with the eye and have uniform drug contents that complied with the US Pharmacopeial (USP) official requirement. In vitro release data of ophthalmic formulations showed a sustained release without any burst effect and the formulations followed a Higuchi non-Fickian diffusion mechanism. The results of in vitro cell toxicity revealed that all the prepared formulations are non-toxic, as the percentage cell viability ranged from 89.9 to 97.7%. Conclusions: These formulations provide a great deal of flexibility to the formulation scientist whereby the sizes and zeta potentials of the formulations can be tuned to suit the need using scalable and robust methodologies. This could thus serve as a potential drug delivery system for both the anterior and posterior eye diseases.