For stability conditions on K3 surfaces, we study moduli stacks of semistable objects with Donaldson–Thomas type invariants, introduced by Joyce, and mock theta functions, introduced by Ramanujan. In particular, we will show invariance of moduli stacks on faithful stability conditions and motivic invariants, and in terms of mock theta functions, study generating functions obtained by moduli-stack counting and differential equations.