In advanced device technologies such as microelectromechanical systems (MEMS), nanoscale electronics, optoelectronic components, and piezoelectric devices, the demand for enhanced mechanical, electrical, and optical performance together with high reliability continues to grow. In response, a variety of functional thin-film materials have been developed; among them, Pb(Zr,Ti)O₃ (PZT) thin films with high piezoelectric coefficients have emerged as key materials for realizing highperformance sensors and actuators. However, residual stress within thin films can adversely affect device reliability, performance, and lifetime. This tutorial paper provides a practical and step-by-step guide to residual stress analysis using X-ray diffraction (XRD) based on the sin²φ method. As a representative case study, we quantitatively analyze the in-plane residual stress of a PZT thin film deposited on a flexible metal-foil substrate. Residual stress was evaluated using X-ray diffraction (XRD) in combination with the sin²φ method. The present analysis is expected to deepen understanding of residual-stress behavior in thin films and to inform stress-aware design and reliability optimization of PZT-based devices