DEV Community

Surendra Singh Kamboj
Surendra Singh Kamboj

Posted on AI-assisted

Basic buffers in JavaScript: why an ammonia/ammonium chloride mix sits above pH 8, not at pH 7

Acidic buffers (acetic acid + acetate) are the textbook default, but a basic buffer made from a weak base and its salt works the same way, just mirrored: ammonium hydroxide (NH4OH) plus ammonium chloride (NH4Cl) holds the pH comfortably basic, around 9, instead of neutral.

function basicBufferPH({ Kb, saltToBaseRatio }) {
  const pKb = -Math.log10(Kb);
  const pOH = pKb + Math.log10(saltToBaseRatio);
  return 14 - pOH;
}

const Kb = 1.8e-5; // NH4OH
console.log(basicBufferPH({ Kb, saltToBaseRatio: 1 }).toFixed(2)); // 9.26
console.log(basicBufferPH({ Kb, saltToBaseRatio: 3 }).toFixed(2)); // 8.78
Enter fullscreen mode Exit fullscreen mode
Salt (NH4Cl) : Base (NH4OH) pH
1 : 1 9.26
3 : 1 8.78

Equal parts salt and base gives pH 9.26 (14 - pKb, mirroring the acidic case's pH = pKa). Add more of the salt (NH4Cl) relative to the base and the pH drops a little, toward neutral — because more NH4+ means more of the conjugate acid around to soak up any extra OH-.

Where this buffer is actually used

This exact mixture (NH4OH/NH4Cl, pH about 9-10) is the standard buffer in qualitative salt analysis (Class 11/12 inorganic practicals) to precipitate group III radicals (Fe3+, Al3+, Cr3+) as hydroxides while keeping group IV ions (Zn2+, Mn2+ etc.) in solution — the whole separation scheme depends on holding that pH steady while H2S is passed through.

A common mistake

Assuming a basic buffer's pH is just "14 minus the acidic buffer's pH" when the salt:base ratio is anything other than 1:1 — the log term flips sign for pOH vs pH, so a ratio that pushes an acidic buffer's pH up pushes a basic buffer's pH down (toward neutral), not up.

Try changing the ratio yourself on PractiSci's buffer solution lab, alongside the Class 11 chemistry practicals.

Full disclosure: I build PractiSci, a free virtual physics and chemistry lab for Class 11-12.

Top comments (0)