When a weak acid dissolves in water, it establishes an equilibrium between the undissociated acid and its ions: $$ HA(aq) \rightleftharpoons H^+(aq) + A^-(aq) $$
The equilibrium constant for this reaction is called the acid ionization constant ($K_a$): $$ K_a = \frac{[H^+][A^-]}{[HA]} $$
[H⁺]: Concentration of hydrogen ions (or hydronium ions, $H_3O^+$).
[A⁻]: Concentration of the conjugate base.
[HA]: Concentration of the undissociated acid.
Hint
A larger $K_a$ indicates a stronger acid because more $HA$ dissociates, producing more $H^+$ ions.
Conversely, a smaller $K_a$ indicates a weaker acid.
Example
Acetic acid ($CH_3COOH$) has a $K_a$ of $1.8 \times 10^{-5}$.
This small value shows that acetic acid is a weak acid, as only a small fraction of its molecules dissociate in water.
This is why vinegar, which contains acetic acid, has a sour but not overpowering taste.
Base Ionization Constant ($K_b$)
For weak bases, the reaction in water can be represented as: $$B(aq) + H_2O(l) \rightleftharpoons BH^+(aq) + OH^-(aq)$$
The base ionization constant ($K_b$) is defined as: $$K_b = \frac{[BH^+][OH^-]}{[B]}$$
[OH⁻]: Concentration of hydroxide ions.
[BH⁺]: Concentration of the conjugate acid.
[B]: Concentration of the undissociated base.
Hint
As with acids, a larger $K_b$ corresponds to a stronger base, while a smaller $K_b$ indicates a weaker base.
Example
Ammonia ($NH_3$) has a $K_b$ of $1.8 \times 10^{-5}$.
This indicates that ammonia is a weak base, as it only partially ionizes in water.
This is why ammonia solutions are less caustic compared to strong bases like sodium hydroxide.
Tip
You can estimate the strength of an acid or base by comparing its $K_a$ or $K_b$ to 1.
Strong acids/bases typically have $K_a$ or $K_b > 1$, while weak acids/bases have values much smaller than 1.
$pK_a$ and $pK_b$: A Logarithmic Perspective
Working with very small $K_a$ and $K_b$ values can be cumbersome.
To simplify comparisons, we use their negative logarithms: $$ pK_a = -\log_{10}(K_a) \quad \text{and} \quad pK_b = -\log_{10}(K_b) $$
Lower $pK_a$: Indicates a stronger acid (larger $K_a$).
Lower $pK_b$: Indicates a stronger base (larger $K_b$).