
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
count-tokens
Advanced tools
A simple CLI tool to count tokens in files or clipboard content using tiktoken
A simple CLI tool to count tokens in files or clipboard content using OpenAI's tiktoken library.
npm install -g count-tokens
or with bun:
bun add -g count-tokens
count-tokens [file] [options]
-m, --model <model>
- OpenAI model to use for encoding (default: "gpt-4")-e, --encoding <encoding>
- Specific encoding to use (overrides model)-d, --details
- Show detailed token information including character count and cost estimates-c, --chunks <size>
- Split output into chunks of specified token size--clipboard
- Count tokens from clipboard content instead of a file-h, --help
- Display help-V, --version
- Display versionCount tokens in a file using the default GPT-4 encoding:
count-tokens myfile.txt
Count tokens using GPT-3.5 Turbo encoding:
count-tokens myfile.txt --model gpt-3.5-turbo
Show detailed information including cost estimates:
count-tokens myfile.txt --details
Show chunk breakdown for 4096 token chunks:
count-tokens myfile.txt --chunks 4096
Use a specific encoding directly:
count-tokens myfile.txt --encoding cl100k_base
Count tokens from clipboard content:
count-tokens --clipboard
Count clipboard tokens with GPT-3.5 Turbo encoding:
count-tokens --clipboard --model gpt-3.5-turbo
Show detailed information for clipboard content:
count-tokens --clipboard --details
Copy text and immediately count tokens (macOS):
echo "Your text here" | pbcopy && count-tokens --clipboard
Copy text and immediately count tokens (Linux):
echo "Your text here" | xclip -selection clipboard && count-tokens --clipboard
bun install
bun run index.ts <file>
MIT
FAQs
A simple CLI tool to count tokens in files or clipboard content using tiktoken
We found that count-tokens demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.