# Calculate how much hydrogen or oxygen will be produced in the electrolysis of water

Is there a way to exactly calculate the quantity of hydrogen or oxygen in a water electrolysis? I am thinking of a plain and simple electrolysis like an anode and kathode in salted water separating oxygen and hydrogen. The formula I am looking for would look like this:

hydrogen(quantity) = (water(quantity) + salt(quantity) + volt + ampere) * time


or

oxygen(quantity) = (water(quantity) + salt(quantity) + volt + ampere) * time


I'm not sure it's appropriate to explain the relationship between all the variables above, here, as there are a lot of concepts that would need to be explored. However, fundamentally (assuming there are no other reactions apart from the electrolysis) the charge passed through the cell is proportional to the amount of products formed, described by Faraday's laws of electrolysis. Here is a useful rearrangement: $$n = \frac{Q}{Fz}$$ Where $Q$ is the charge passed, $F$ is the Faraday constant and $z$ is the number of electrons transferred per redox reaction. For example, $z = 2$ for hydrogen because it takes two electrons to convert $\ce{H+}$ to $\ce{H2}$ as $\ce{2H+ + 2e- <=> H2}$. Therefore, for every coulomb of charge, we get: \begin{align} n &= \frac{1\ \mathrm{C}}{(96.485\ \mathrm{kC/mol})(2)}\\ &= 5.18\ \mathrm{µmol} \end{align} of hydrogen gas produced. So if we can measure the charge (or current integrated over time), we can calculate the amount of product produced. This is true no matter what voltage is applied or what the electrolyte content of the solution is, however if more than one reaction is occurring at an electrode, you won't be able to separate the contributions from each reaction with only the charge as information. There will also be a minor contribution from charging the double layer capacitance when the potential is first applied.