Dev.to WebDev 🛠 Dev 👁 0 📖 1 min read

Why soap always needs exactly 3 NaOH per fat molecule: saponification in 10 lines of JavaScript

Soap-making looks like magic until you write down the stoichiometry. A fat is a triglyceride with 3 ester bonds, and each one needs its own molecule of base to break. Here it is checked in JavaScript. The react

Soap-making looks like magic until you write down the stoichiometry. A fat is a triglyceride with 3 ester bonds, and each one needs its own molecule of base to break. Here it is checked in JavaScript.

The reaction

A triglyceride (fat/oil) + 3 NaOH (or KOH) -> glycerol + 3 molecules of soap (a fatty-acid salt). This is saponification: alkaline hydrolysis of an ester, and it only goes one way because the carboxylate ion formed will not re-attack the alcohol.

Saponification value, computed

The saponification value (SV) is "mg of KOH needed to saponify 1 g of fat." For tristearin (glyceryl tristearate, M = 891.5 g/mol, 3 ester groups):

const KOH_mg_per_mol = 56100;     // 56.1 g/mol KOH, in mg
const esterGroups = 3;            // one per fatty-acid chain
const M_tristearin = 891.5;       // g/mol
const SV = (esterGroups * KOH_mg_per_mol) / M_tristearin;
console.log(SV.toFixed(1));       // 188.8

That 188.8 mg KOH/g is why soap chemists use SV to tell fats with short fatty-acid chains (high SV) apart from fats with long chains (low SV) — smaller molecules need relatively more base per gram.

Mass balance for 10 g of fat

const mass_g = 10;
const moles_fat = mass_g / 891.5;      // 0.01122 mol
const moles_NaOH = moles_fat * 3;      // 0.03365 mol
const g_NaOH = moles_NaOH * 40;        // 1.35 g
const g_glycerol = moles_fat * 92;     // 1.03 g
const g_soap = moles_NaOH * 306.5;     // sodium stearate, 10.31 g
console.log({g_NaOH, g_glycerol, g_soap});

10 g of tristearin needs 1.35 g of NaOH, and gives back 1.03 g of glycerol plus 10.31 g of soap — the mass balances (10 + 1.35 = 1.03 + 10.31, allowing for rounding).

Two things people get wrong

  1. Writing the equation with only 1 NaOH instead of 3 — every triglyceride has 3 ester bonds to break.
  2. Mixing up saponification value with iodine value. SV measures average chain length via ester-bond count; iodine value measures the number of C=C double bonds (unsaturation), which is a completely separate property.

Try it yourself

I build PractiSci, and its free saponification lab lets you pick the fat and the base and watch the mass balance update live. More labs: practisci.in/practicals/class-12-chemistry.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.