know something backwards and forwards and know something forwards and backwards
Fig. to know something very well; to know a passage of language so well that one could recite it backwards as well as forwards. Of course I've memorized my speech. I know it backwards and forwards.