Searching for electrode materials with good electrical conductivity, fast charge/discharge rates and high storage capacity is essential for the development of high-performance metal ion batteries. Here, by performing first principles calculations, we have explored the feasibility of using two dimensional (2D) covalent organic frameworks (COFs) constructed by tri-quinazoline, triquinoxalinylene and benzoquinone, and tribenzoquinoxaline-5,10-dione and benzoquinone (BQ2), as electrode materials for lithium and sodium ion batteries. All the designed 2D COFs show good structure stability and are semiconductors with a band gap of 1.63-2.93 eV because of the high electron conjugation of the skeletons. The pyrazine N and carbonyl groups are revealed to be the active sites to combine Li/Na, while the Li-/Na-binding strength can be highly enhanced when the pyrazine N and the carbonyl group are located in adjacent sites. The designed 2D COFs show a low Li and Na diffusion barrier in the range of 0.28-0.56 eV to guarantee high rate performance for LIBs/SIBs. With abundant redox active sites, 2D BQ2-COF shows a high theoretical capacity of 1030 mA h g-1 with an average open circuit voltage of 0.80 and 0.67 V for LIBs and SIBs, respectively, which is comparable to that of the most advanced inorganic anode materials. Composed of only light elements, the designed 2D COFs are predicted to be promising anode materials with high energy density, good conductivity and high-rate performance for sustainable LIBs and SIBs.