The trick is to write the $j$-invariant function in terms of Eisenstein series, whose $q$-expansions have a simple expression. See Silverman's "Advanced Topics in the Arithmetic of Elliptic Curves", Chapter 1, Section 7, and in particular, Proposition 7.4 and Remark 7.4.1.
In particular $$j(\tau) = 1728\frac{g_2(\tau)^3}{\Delta(\tau)}=1728 \frac{g_2(\tau)^3}{g_2(\tau)^3-27g_3(\tau)^2} = \frac{\left(1+240\sum_{n\geq 1}\sigma_3(n)q^n\right)^3}{q\prod_{n\geq 1}(1-q^n)^{24}}.$$1}(1-q^n)^{24}},$$or, if you prefer,$$j(\tau) = 1728 \frac{\left(1+240\sum_{n\geq 1}\sigma_3(n)q^n\right)^3}{\left(1+240\sum_{n\geq 1}\sigma_3(n)q^n\right)^3 - \left(1-504\sum_{n\geq 1}\sigma_4(n)q^n\right)^2}.$$2 Added explicit formula; added 2 characters in body The trick is to write the j-invariant function in terms of Eisenstein series, whose q-expansions have a simple expression. See Silverman's "Advanced Topics in the Arithmetic of Elliptic Curves", Chapter 1, Section 7, and in particular, Proposition 7.4 and Remark 7.4.1. In particular$$j(\tau) = 1728\frac{g_2(\tau)^3}{\Delta(\tau)}=1728 \frac{g_2(\tau)^3}{g_2(\tau)^3-27g_3(\tau)^2} = \frac{\left(1+240\sum_{n\geq 1}\sigma_3(n)q^n\right)^3}{q\prod_{n\geq 1}(1-q^n)^{24}}.
The trick is to write the $j$-invariant function in terms of Eisenstein series, whose $q$-expansions have a simple expression. See Silverman's "Advanced Topics in the Arithmetic of Elliptic Curves", Chapter 1, Section 7, and in particular, Proposition 7.4 and Remark 7.4.1.