Derivation (charge conservation)

For an arbitrary time-independent volume $V$ with boundary $S = \partial V$, charge conservation means $$ \begin{align*} \dfd{Q}{t} = -I \end{align*} $$ where $Q = \int_{V} ρ \d V$ is the total charge in $V$ and $I = \int_{S} \v J\cdot \d \v S$ is the current flowing out of $S$.

Then by divergence theorem, $$ \begin{align*} \int_{V} \pdfd{ρ}{t} + ∇\cdot \v J \d V = 0, \end{align*} $$ and is true for any $V$. So the integrand is zero anywhere.