ehemalig
former
Indicates that someone or something previously had a particular quality, position, or function, but no longer has it now.
Der ehemalige Präsident besuchte seine alte Schule.
The former president visited his old school.

former
Loading your saved state.
former
Indicates that someone or something previously had a particular quality, position, or function, but no longer has it now.
Der ehemalige Präsident besuchte seine alte Schule.
The former president visited his old school.

The word is derived from 'ehemals' (formerly), which means 'früher' (earlier / formerly). It is related to 'ehe' (before) and 'Mal' (point in time) and describes a state that applied at an earlier time.
Das Gebäude war ehemals eine Schule, heute sind dort Wohnungen.
The building was formerly a school; today there are apartments there.
'Ehemalig' (former) is used almost exclusively attributively, meaning directly before a noun. You cannot say: 'Das Gebäude ist ehemalig.' (The building is former.)
Das ist der ehemalige Bahnhof der Stadt.
That is the city's former train station.
The adjective is very often used in connection with professions, titles, relationships, or the former function of places and buildings.
Der ehemalige Profisportler arbeitet jetzt als Trainer.
The former professional athlete now works as a coach.
old
'alt' and 'ehemalig' can both express that something belongs to an earlier time. 'ehemalig' is clearer: 'eine ehemalige Lehrerin' (a former teacher) or 'ein ehemaliger Chef' (a former boss) no longer has that role now. In this meaning, 'alt' can also mean 'former' or 'previous', for example 'mein alter Chef' (my former boss). But 'alt' can also simply mean great age or a used condition. That is why misunderstandings can easily arise. If you want to say clearly that a person or role is no longer current, 'ehemalig' is more precise.

Ich habe gelesen, dass die ehemalige Bürgermeisterin jetzt ein Buch schreibt.
I read that the former mayor is now writing a book.
In der E-Mail erwähnt Paul seinen alten Lehrer aus dem Deutschkurs.
In the email, Paul mentions his former teacher from the German course.