Melatonin is a hormone produced by the pineal gland, and it has extensive beneficial effects on various tissue and organs; however, whether melatonin has any effect on cardiac fibrosis in the pathogenesis of diabetic cardiomyopathy (DCM) is still unknown. Herein, we found that melatonin administration significantly ameliorated cardiac dysfunction and reduced collagen production by inhibiting TGF‐β1/Smads signaling and NLRP3 inflammasome activation, as manifested by downregulating the expression of TGF‐β1, p‐Smad2, p‐Smad3, NLRP3, ASC, cleaved caspase‐1, mature IL‐1β, and IL‐18 in the heart of melatonin‐treated mice with diabetes mellitus (DM). Similar beneficial effects of melatonin were consistently observed in high glucose (HG)‐treated cardiac fibroblasts (CFs). Moreover, we also found that lncRNA MALAT1 (lncR‐MALAT1) was increased along with concomitant decrease in microRNA‐141 (miR‐141) in DM mice and HG‐treated CFs. Furthermore, we established NLRP3 and TGF‐β1 as target genes of miR‐141 and lncR‐MALAT1 as an endogenous sponge or ceRNA to limit the functional availability of miR‐141. Finally, we observed that knockdown of miR‐141 abrogated anti‐fibrosis action of melatonin in HG‐treated CFs. Our findings indicate that melatonin produces an antifibrotic effect via inhibiting lncR‐MALAT1/miR‐141‐mediated NLRP3 inflammasome activation and TGF‐β1/Smads signaling, and it might be considered a potential agent for the treatment of DCM.