When it comes to whether or not to input a comma before the clause “such as”, it is important to consider the context.
Typically, commas are used before “such as” in non-essential clauses. i.e. clauses that make up a part of a sentence, but can be removed without warping the meaning of the sentence. In other words, if the sentence can function without a nonessential clause, “such as” shouldn’t be preceded by a comma.
“Footwears such as Nike are my favourite shoes.” (essential clause)
“Her house is filled with animals, such as dogs and cats” (non-essential clause).