A potential divider is perfectly fine:
simulate this circuit – Schematic created using CircuitLab
If there's any chance that the input might stray outside the bounds 0V to 12V, this will also restrict current flowing via the input protection diodes of the GPIO line.