As part of a recent audit that I was doing of Google Font usage in a codebase, I had a need to get a list of all Google Fonts. But, after a bit of searching, I wasn’t finding an easily consumable list of these fonts.
But, it turns out that if you get an Google Fonts API key from the Google Cloud Console, then it’s super simple to query and get a list of fonts. Actually, this is what getting a list of Google Fonts looks like with a single command from the terminal.
curl --location --request GET 'https://www.googleapis.com/webfonts/v1/webfonts?key=...' | jq ".items[] | .family" --raw-output
To get this to work, simply replace the ...
with your actual key and then run the command.
Of note, this command does assume that you’ve got jq
installed which is used to parse the JSON response. But, if you’d like, you can simply remove the everything after from the | jq
and after to echo the json.
Leave a Reply