Patients with autoimmune and/or inflammatory diseases (AIIDs) are prone to serious infectious complications such as Pneumocystis jirovecii pneumonia (PJP). In non-HIV patients, the prognosis is poorer, and diagnostic tests are of lower sensitivity. Given the low incidence of PJP in AIIDs, with the exception of granulomatosis with polyangiitis, and the non-negligible side effects of chemoprophylaxis, routine prescription of primary prophylaxis is still debated. Absolute peripheral lymphopenia, high doses of corticosteroids, combination with other immunosuppressive agents, and concomitant lung disease are strong predictors for the development of PJP and thus should warrant primary prophylaxis. Trimethoprim-sulfamethoxazole is considered first-line therapy and is the most extensively used drug for PJP prophylaxis. Nevertheless, it may expose patients to side effects. Effective alternative drugs such as atovaquone or aerosolized pentamidine could be used when trimethoprim-sulfamethoxazole is not tolerated or contraindicated. No standard guidelines are available to guide PJP prophylaxis in patients with AIIDs. This review covers the epidemiology, risk factors, and prevention of pneumocystis in the context of AIIDs.