GA4 has a setting for this. Admin, Data streams, your web stream, Tagging settings, then the option to remove unwanted query parameters from page URLs. You supply a list of parameter names and GA4 strips them from the reported URL.
Leave utm parameters and click IDs alone. GA4 needs them to determine source and campaign. Strip them and your attribution collapses into direct traffic.
Do clean up: CMS session IDs, filter and sort parameters, internal search parameters, and whatever your testing or personalisation tool appends.
If you would rather fix it at the source, build a GTM variable that rewrites page_location before the GA4 tag fires. That gives you more control and costs maintenance every time a new parameter appears. For most sites the GA4 setting is enough.