Bacterial endophthalmitis (BE) is a severe ocular infection that can lead to irreversible blinding ocular disease. When diagnosed with BE, the main treatment approach is empirically administering intravitreal antibiotic injections. However, the excessive use of antibiotics leads to increased drug resistance in pathogens, and the retinal dose-limiting toxicities greatly limit its application in clinic. In this work, we present a series of polylysine derivatives (PLL-n) for the treatment of bacterial endophthalmitis. By precisely adjusting the balance of hydrophilic/hydrophobic, the optimal polymer, PLL-2, demonstrates high efficacy against Staphylococcus aureus (S. aureus), Escherichia coli (E. coli), and various clinically isolated drug-resistant bacteria. The antibacterial mechanism showed that PLL-2 could effectively destroy the bacterial membrane and lead to bacterial death. Due to its unique antibacterial mechanism, PLL-2 exhibits rapid bactericidal kinetics and does not induce bacterial resistance up to 16 generations. More importantly, PLL-2 showed a significant therapeutic effect on a methicillin-resistant S. aureus-induced rat endophthalmitis model, which presents a promising therapeutic approach for managing endophthalmitis.