off the top of one’s head
Explanation: When you do something off the top of your head, you do it without prior preparation.
How to use it: [someone] knows [something] off the top of their head
Example: The boss suddenly asked me to give a speech at the meeting, so I did it off the cuff.