Should there be spaces around an em dash?
Typically, there is no space around an em dash (e.g., “The flight—which had already been delayed three times—was canceled”).
One notable exception is that Associated Press (AP) style requires spaces around an em dash, so you may see this in news articles (e.g., “The flight — which had already been delayed three times — was canceled”).
Consult your style guide to see what is preferred. All of the major academic style guides (APA, MLA, and Chicago) recommend not putting spaces around em dashes.
QuillBot’s Grammar Checker can help you make sure you are using em dashes correctly.