Comma Before "But"
* When "but" introduces a contrasting or opposing idea in a compound sentence:
* *The weather was beautiful, but the beach was crowded.*
* *I wanted to stay, but I had to leave.*
Comma After "But"
* Generally, you don't use a comma after "but."
Exceptions:
* When "but" is used as an interjection:
* *I'm going to the store, but, wait, I need to grab my wallet first.*
* When "but" introduces a parenthetical phrase or element:
* *The movie was excellent, but, as usual, I fell asleep halfway through.*
Key Takeaway:
Think of "but" as a connector between two independent clauses. If the clauses could stand alone as separate sentences, a comma usually goes before "but."