Inspired by the dynamic morphology control of molecular assemblies in biological systems, we have developed pH-responsive transformable peptide-based nanoparticles for photodynamic therapy (PDT) with prolonged tumor retention times. The self-assembled peptide–porphyrin nanoparticles transformed into nanofibers when exposed to the acidic tumor microenvironment, which was mainly driven by enhanced intermolecular hydrogen bond formation between the protonated molecules. The nanoparticle transformation into fibrils improved their singlet oxygen generation ability and enabled high accumulation and long-term retention at tumor sites. Strong fluorescent signals of these nanomaterials were detected in tumor tissue up to 7 days after administration. Moreover, the peptide assemblies exhibited excellent anti-tumor efficacy via PDT in vivo. This in situ fibrillar transformation strategy could be utilized to design effective stimuli-responsive biomaterials for long-term imaging and therapy.