A quick 85th-minute break by the excellent Hackett ended with Nicholls exchanging passes with Platt before rounding Shearer to score from a tight angle.
The first real moment of quality in the match had produced the breakthrough for Cobblers in the 26th minute. Chris Hackett received a short throw-in from Nicholls and cut inside before rifling a fierce drive past Scott Shearer from 20 yards.
Ben Harding went close to doubling Northampton's advantage when his screamer from 25 yards struck the bar.
Rotherham made the most of the let-off, the impressive Ben Pringle seeing his 42nd minute deflected shot from the edge of the box leaving Nicholls stranded.
Substitute Kieran Agard should have given Rotherham the lead midway through the second half, racing onto Kayode Odejayi's flick-on before blazing over from six yards. That miss was to be punished by a late Cobblers winner.