Metal-organic frameworks (MOFs) have attracted considerable attention owing to their multifaceted applications and structurally tunable characteristics. Powder X-ray diffraction (XRD) is an essential technique for high-throughput characterization of MOFs. However, it remains challenging to automatically interpret the XRD data due to the diversity and complexity of the geometric structures of MOFs. Herein, we propose a generative artificial intelligence framework based on the Stable-Diffusion architecture for deciphering the structures of MOFs from powder XRD patterns. This model, named as Xrd2Mof, has incorporated domain-specific knowledge by using a coarse-grained representation scheme, which leads to an accuracy of over 93% in identifying the ground truth MOF structure corresponding to the targeted XRD pattern. Xrd2Mof can be directly applied to a diverse range of MOF structures that cover nearly all types of framework topologies, thereby establishing a novel technological avenue for automated structural analysis of MOFs in self-driving laboratories.