Scour is an open source tool which you can run locally to optimize SVG files. It automatically removes comments. As well as comments, you can set it to strip out metadata and even to shorten IDs. Typically, it will not be installed by default, though you can get it with Homebrew and other package managers.