Yup, I use a long "jq" command [0] as a Git clean filter for my Jupyter notebooks, and it works really well. I use a similar program [1] for Mathematica notebooks, and it also works really well.
[0]: https://stackoverflow.com/a/74104693
[1]: https://github.com/JP-Ellis/mathematica-notebook-filter