Nik, after re-reading your post, I'm not sure what you mean by "unused variables".
IAC, I have posted my macro which will give you a list of all Variables IF you CANCEL the confirmation. The main purpose is to delete all variable except those you want to keep.
[KM] DELETE All Variables Except Those on Keep List
One technical note: This list, which comes from JXA (or AppleScript) does NOT include all KM variables that show in the KM Preferences.
From Peter (@peternlewis):
The preference pane includes variables that are referenced by any macro or that have a value and that is not %Delete%.
The variables result from AppleScript includes variables that have a value and that is not %Delete%.