We can derive a general equation for calculating the pH of any buffer solution. Consider a mixture of weak acid (HX) and its conjugate base.

HX + H_{2}O ⇌ H_{3}O^{+} + X^{–}

K_{a} = [H_{3}O^{+}] [X^{–}] / [HX]

Taking log on both the sides, we will get:

Log K_{a} = log [H_{3}O^{+}] + log ([X^{–}] / [HX])

-log K_{a} = – log [H_{3}O^{+}] – log ([X^{–}] / [HX])

pK_{a} = pH – log ([X^{–}] / [HX])

pH = pK_{a} + log ([X^{–}] / [HX])

The quantity [X^{–}] / [HX] is the ratio of concentration of salt or conjugate base of acid and acid present in the mixture.

Therefore, pH = pK_{a} + log ([salt]/ [base])

This equation is called Henderson – Hasselbalch equation. Similarly, for a basic buffer,

pOH = pK_{b} + log ([salt]/ [base])

pH = 14 – pK_{b} – log ([salt]/ [base])