The word legalism does not occur in the Bible. What is Legalism? Christians use the term to describe a doctrinal position emphasizing a system of rules and regulations for achieving both salvation and spiritual growth. Legalism is an attempt to gain favor with God or to impress our fellow man by doing certain things (or avoiding other things). Doctrinally, this position is essentially opposed to grace.
Legalists believe in and demand a strict literal unqualified adherence to their biblical interpretations, traditions, rules and regulations. Some feel so strongly about some non-essential doctrines or traditions that they excommunicate others from their fellowship for not following them. That is legalism.