Flanker, a Python package which performs alignment-free clustering of gene flanking sequences in a consistent format, allowing investigation of mobile genetic elements (MGEs) without prior knowledge of their structure. Flanker can be flexibly parameterised to finetune outputs by characterising upstream and downstream regions separately and investigating variable lengths of flanking sequence.