Phenolphthalein is a complex weak organic acid (HPh). Its undissociated molecule (HPh) is colourless while its ion (Ph-) is pink in colour. pH range of phenolphthalein is 8 – 9.8.
In acid-base titration as the medium changes from acidic to basic, the following equilibrium shifts to right.
HPh ⇌ H+ + Ph- and solution turns pink from colourless giving its endpoint. When medium changes to acidic, equilibrium shifts to left and the solution becomes colourless.