Automatic categorization

Suppose I have thousands of bank transactions JSON). How can I automatically categorized these, based on the counter account number and/or a free text description that also can identify the counter account.

E.g. some of them should map to “restaurant”, others to “clothing”, some to “food”, etc. The mapping table can be created by hand, or maybe by some ML.

I assume I’m not the first, and there are some practical ways or libraries to do so.

Open to any practical suggestions.

Thanks.