The process of splitting photocatalytic water in order to produce hydrogen under sunlight is one of the most valuable methods to create renewable energy sources. Among different photocatalysts, titanium dioxide is due to its high specific properties such as high stability, environmental compatibility, optical corrosion resistance, these are required features for practical applications and industry use. But it's not active in the visible range and the rapid recombination of the electron-hole in it, it is limited to wide-scale applications. This problems can be solved by doping different elements or coupling with other semiconductors. The doping of non-metals and pseudo-metals leads to increase the valance band and doping the metals leads to reduce the conduction band in the titanium dioxide and thus reduce the titanium dioxide band gap. There are various methods for doping different elements into titanium dioxide, the in situ anodizing method was used because of single-step process, the cost-effectiveness of the method and the availability of tools. Cobalt (transition metal) and boron (metalloid) elements were selected as doping agents in the titanium dioxide structure by in situ anodizing method. The morphology, structure and optical properties of prepared samples were investigated by FE-SEM, Raman, XRD, EDX and UV-Visible techniques. The presence of cobalt and boron elements in nanotubes and the reduction of band gap were confirmed by these techniques. Then, the effect of doping agents concentration on the photoelectrocatalytic activity of titanium dioxide was evaluated by OCP, LSV and CA techniques. The results indicated that nanotubes modified with cobalt and boron show better photocatalytic performance than titanium dioxide nanotubes. The CT15 electrode in the cobalt group and BT10 in the boron group exhibited the most photoelectrocatalytic performance and hydrogen production within one hour.