An ultrathin phosphorus doped hydrogenated microcrystalline silicon oxycarbide (n-μc-SiCO:H) layer deposited by plasma enhanced chemical vapor deposition (PECVD) method can be used as a window layer for silicon heterojunction solar cells. The optical and electrical properties of n-μc-SiCO:H films were controlled by PECVD deposition conditions. The interplay effects of H2, CO2 and PH3 to SiH4 gas ratio on the chemical composition, material structure and properties of n-μc-SiCO:H film were systematically determined. O, H, C and P atoms were observed to incorporate into the silicon network of n-μc-SiCO:H layer, while most of the atoms bond directly to Si atoms. Incorporation of oxygen and carbon atoms into n-μc-SiCO:H film, confirmed by XPS as formation of Si-O and Si-C bonds, enlarged the optical absorption band gap (Eg) value. Both film crystallinity and phosphorus concentration in n-μc-SiCO:H layer were observed to be controlled by the H2, CO2 and PH3 to SiH4 gas ratio. The electric performance of HJT solar cell was depended on the optical and electrical properties of n-μc-SiCO:H layer. An average efficiency (across ∼ 120 cells) of 26.32 % was achieved in cells with optimized deposition parameters for the n-μc-SiCO:H layer. The reaction gas ratio was also the dominant factor in determining the number and size of nanoscale Si crystallites embedded in the n-μc-SiCO:H layer. The conductivity of n-μc-SiCO:H layer was determined by the activated phosphorus concentration but independent of the total phosphorus concentration. It was also found that large concentrations of small Si crystallites of size less than 3 nm improved film conductivity.