TokenEstimator is a Rails gem that allows you to count tokens in Excel, CSV, PDF, TXT, Markdown, and input text files using different tokenizers.
Miniparser works pretty simply. You pass the Gem some input (HTML, JS, or CSS), and it will validate it, return the validated status, then minify it, and return the minified version as either a file (path) and a text return, respective to what input it got