Idiopathic pulmonary fibrosis (IPF) is a severe progressive lung disease characterized by fibrotic changes in lung tissue, with limited treatment options. This study analyzed gene expression data from three gene expression omnibus datasets (GSE2052, GSE53845, and GSE110147) using R and LIMMA to identify differentially expressed genes (DEGs) in IPF samples. We identified 215 DEGs, comprising 106 upregulated and 109 downregulated genes. Weighted gene coexpression network analysis revealed five gene modules, with the module eigengene yellow showing the strongest correlation with IPF. Functional enrichment analysis of 40 consensus genes in this module indicated their significant involvement in extracellular matrix (ECM) organization. Kyoto Encyclopedia of Genes and Genomes pathway analysis revealed pathways related to protein digestion, cell adhesion molecules, and the advanced glycation end product–receptor for advanced glycation end product signaling pathway. Based on protein–protein interaction network analysis, collagen type XV alpha 1 chain (COL15A1) and collagen type VI alpha 3 chain (COL6A3) were identified as upregulated hub genes in IPF, which were regulated by microRNAs and transcription factors. Immune cell infiltration analysis showed significant changes in immune cell populations in IPF samples, with increases in memory B cells, plasma cells, and M0 macrophages and decreases in CD8 T cells, and resting natural killer cells. Potential drugs targeting COL15A1 and COL6A3 were predicted using multiple databases, revealing compounds such as (+)-JQ1, aristolochic acid I, and dexamethasone with promising binding potential. These findings suggest that COL15A1 and COL6A3 are central hub genes in IPF, are associated with ECM organization and immune response, and serve as therapeutic targets for IPF.