The change of this name dates back to the Ming Dynasty. When Zhu Yuanzhang ended the rule of the Yuan Dynasty and established the Ming Dynasty, he changed Chang'an to Xi'an. Anxi Prefecture was established during the Yuan Dynasty, which means stability in the west. The new monarch must change this name when he takes office, so Zhu Yuanzhang named Chang'an Xi'an, which means stability in the west.
If Xi'an was the capital, it would definitely not be called this name. Originally, Zhu Yuanzhang also had the intention to move the capital to Xi'an. He sent Zhu Biao, his favorite, as his successor. His son Zhu Biao went to Xi'an for investigation first. As a result, after Zhu Biao came back, for unknown reasons, he suddenly started to fall ill, and his illness was quite serious. He died not long after.
Because of Zhu Biao's accidental death, Zhu Yuanzhang never thought of moving the capital to Xi'an. As a result, Xi'an was not designated as the capital, and the name naturally remained unchanged. The first person in history to set Xi'an as the capital was King Wen of Zhou, who named it Fengjing. After King Wen passed the throne to Queen Wu of Zhou, it was renamed Haojing. The real name of Chang'an was actually Liu Bang. After Liu Bang became the emperor of the Han Dynasty, he established this place as Chang'an County and also established Weiyang Palace.
Soon after, the capital was moved to Chang'an Township, so Chang'an Township was named Chang'an City. Chang'an means long-term peace and stability, and Weiyang means beauty. Originally, Liu Bang wanted to build a capital in his hometown, but Xiang Yu's establishment of a capital in his hometown did not go as smoothly as he imagined. With this in mind, Liu Bang gave up the idea. At this time, Zhang Liang suggested to Liu Bang that Chang'an be the capital. At that time, it was not called Chang'an, and it was not called Chang'an until the capital was established.