comes into head

something comes into your head

you think or remember something It just came into my head that I should give my money away and throw myself on God's mercy.
Usage notes: sometimes used in the form the first thing that comes into your head (the first thing you think of): Mrs. Winn said the first thing that came into her head.
See also: come, head