A buffer's pH depends on the ratio of base to acid. Rearranging $K_a$ and taking logarithms gives a formula that shows this directly.
🔑 Key idea
$$\text{pH} = \text{p}K_a + \log\frac{[\mathrm{A^-}]}{[\mathrm{HA}]}$$
When the two are equal, $\text{pH} = \text{p}K_a$. Every factor of 10 in the ratio moves the pH by 1.
💡 Why it works
Start from $K_a = \dfrac{[\mathrm{H_3O^+}][\mathrm{A^-}]}{[\mathrm{HA}]}$ and solve for $[\mathrm{H_3O^+}] = K_a\dfrac{[\mathrm{HA}]}{[\mathrm{A^-}]}$. Take $-\log$ of both sides: $-\log[\mathrm{H_3O^+}] = -\log K_a - \log\dfrac{[\mathrm{HA}]}{[\mathrm{A^-}]}$, that is, $\text{pH} = \text{p}K_a + \log\dfrac{[\mathrm{A^-}]}{[\mathrm{HA}]}$. In a buffer both are present in large amounts, so so little ionizes that you can use the amounts you mixed. Since both share the same volume, a ratio of moles works as well as a ratio of molarities.
The fractions of HA and A⁻ against pH. They cross at pH = pKa, and one unit away the ratio is 10 to 1.
Worked examples
✏️ Worked example: pH of an acetate buffer
A buffer has $[\mathrm{CH_3COO^-}] = 0.15\ \text{M}$ and $[\mathrm{CH_3COOH}] = 0.10\ \text{M}$ ($\text{p}K_a = 4.74$). Find its pH.
For a base buffer you can work with $K_b$ instead: $\text{pOH} = \text{p}K_b + \log\dfrac{[\mathrm{HB^+}]}{[\mathrm{B}]}$, then $\text{pH} = 14.00 - \text{pOH}$. It gives the same answer as using the $\text{p}K_a$ of the conjugate acid, which is usually quicker. Read the other way, the equation says the $\text{p}K_a$ of an acid is the pH at which it is exactly half ionized, which is how $\text{p}K_a$ values are measured.
⚠️ Common mistake
Putting the acid over the base inside the log, which flips the sign of the correction. Check: more base than acid must give a pH above the $\text{p}K_a$; more acid, below. Remember "base over acid," as in the order the reaction makes them.
The equation works well when both concentrations are at least about 100 times $K_a$ and the ratio is between 0.1 and 10. Outside those limits, solve the equilibrium in full.
Practice
Pass with 3 right answers, the last 2 in a row. Each right answer earns 2 XP.