The aim of this study was to investigate the production of polyhydroxybutyrate (PHB) by Spirulina sp., a type of cyanobacterium recognized for its capacity to produce this biopolymer. PHB accumulation takes place in Spirulina when it undergoes nitrogen and phosphorus limitation, and carbon abundance, acting as a vital reserve material for the microorganism. The study was conducted under autotrophic conditions, phosphorous deficiency, and varying acidity levels to confirm how the interplay between phosphorus deficiency and pH can affect PHB production in Spirulina without reducing microalgal biomass. Microalgal cultures in the phosphorus-free treatments at pH 8, 10, and 12 were performed, and their growth quality including levels of photosynthetic pigments, malondialdehyde, anthocyanin, phenol, and flavonoid were measured. PHB was extracted and analyzed using Fourier Transform Infrared (FTIR) spectroscopy for qualitative analysis and gas chromatography (GC) for quantitative evaluation. The amounts of anthocyanins, phenols, and flavonoids, which are important constituents of the antioxidant defense system, were highest in the treatment with a pH of 10, which also had the lowest levels of the stress indicator malondialdehyde. The extracted polyhydroxybutyrate amounts in the control treatment and treatments with phosphorus deficiency at pH levels of 8, 10, and 12 were 6.82%, 3.54%, 7.04%, and 4.23% of cell dry weight, respectively, according to GC. Based on the results, altering the acidity of the Spirulina culture medium had a limited effect on increasing in polyhydroxybutyrate accumulation compared to optimal acidity conditions and simultaneous phosphorus removal, which was partly due to the consumption of some polyhydroxybutyrate produced under phosphorus deficiency stress.