The invention discloses a preparation method and application of a carbon nitride ultrathin heterojunction. The method comprises the following steps: carrying out ultrasonic treatment and stirring on negatively-charged ultrathin hydrogen production g-C3N4 in a hydrochloric acid aqueous solution to enhance the dispersity of g-C3N4, wherein the g-C3N4 molecules contain rich -C-N-structures, so that the g-C3N4 molecules can be easily protonated by hydrochloric acid so as to be positively charged; and then carrying out ultrasonic treatment and stirring on the obtained positively-charged ultrathin hydrogen production g-C3N4 and negatively-charged ultrathin oxygen production g-C3N4 in a water phase environment, wherein the positively-charged ultrathin hydrogen production g-C3N4 and the negatively-charged ultrathin oxygen production g-C3N4 can be effectively assembled by utilizing the principle that positive charges and negative charges attract each other, so that the effective combination ofthe hydrogen production semiconductor and the oxygen production semiconductor is achieved so as to successfully construct the ultrathin g-C3N4 heterojunction for photolysis of water. According to theinvention, the obtained ultrathin g-C3N4 heterojunction is excellent in water photolysis performance and good in dispersity and can be stably stored; and the method is simple, high in controllability,good in repeatability, cheap in raw materials, wide in source, safe and environmentally friendly, the production efficiency is improved, the production cost is reduced, and the method is suitable forlarge-scale production.