The phone's own filters
iPhone can separate texts from unknown senders, and Messages by Google has spam protection on many Android phones. They are a good first step and need no extra app, but you cannot add your own list of words on iPhone.
Your carrier
In some countries you can forward a spam text to a short number, for example 7726 in the US, the UK and Canada. It helps the carrier act on the sender; it does not filter by your own words.
Apps with a shared database
These apps compare senders or messages with a list collected from many users. They can recognise senders you have never seen. Check each app's privacy policy for what it sends to its servers.
Apps that follow your own rules
You write the words, numbers and prefixes; the app checks each text against them. ZeroSpam works this way and checks texts on your device: message content is never sent to us. The trade-off is that your rules catch what you put in them; the optional AI filter (Pro) adds built-in lists of common spam words, also matched on the device.

