take it into head to

take it into your head to do something

to decide to do something Uncle Julian might take it into his head to say almost anything.
Usage notes: usually said about doing something silly or surprising
See also: head, take