I don’t agree with Sophia Wang. So I look up these words in Chinese dictionary(现代汉语词典). Here is my answer.
寂寞、孤單、孤獨、孤寂
These four words are similar. All of them can mean alone and lonely. But there is a subtle difference.
1、寂寞 is synonymous with 孤寂. Both of them are more likely focused on the lonely feeling.
In the daily life , 寂寞 is more colloquial/casual. 孤寂 is more formal/written. I will say “我很寂寞” and never say “我很孤寂”. When you write a composition, you can write down “他一个人呆在家里,感到十分孤寂。”
2、孤單 is synonymous with 孤獨. Both of them put more emphasis on the fact that you are alone.
孤單is a little bit more about the fact that you are alone (vs 孤獨) . Sometimes it means you don’t have enough power to fight against others. I think they can be exchangeable mostly.