The solution will depend on exactly what you are trying to detect.
If your goal is to detect the presence of high voltages, a resistive divider + current limiting diode would be sufficient.
If you want to detect the presence of high ac voltage, you may have to rectify the signal, and or detect its repeated presence.
If you want nto detect the presence of 50hz high ac voltage, you may have to count the cycles.
...
using a transformer or opto-coupler helps ensure safety.