Catalyzes the oxidation of glucose 6-phosphate to 6-phosphogluconolactone. Can utilize either NADP(+) or NAD(+). D-glucose 6-phosphate + NAD(+) = 6-phospho-D-glucono-1,5-lactone + H(+) + NADH D-glucose 6-phosphate + NADP(+) = 6-phospho-D-glucono-1,5-lactone + H(+) + NADPH Optimum pH is 5.4-8.9. Carbohydrate degradation; pentose phosphate pathway; D-ribulose 5-phosphate from D-glucose 6-phosphate (oxidative stage): step 1/3. Homodimer. Belongs to the glucose-6-phosphate dehydrogenase family.