A lightweight Node.js CLI tool for analyzing prompt token counts and estimating LLM costs using GPT-compatible tokenization.
The fastest way to install a skill directly from the registry.
npx clawhub@latest install prompt-token-analyzer
Copy the skill folder to one of these locations
~/.openclaw/skills/ <project>/skills/ Priority: Workspace > Local > Bundled
Copy this prompt to OpenClaw to install it automatically.
Help me install prompt-token-analyzer using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).
Get the raw skill files in a ZIP archive.
The Prompt Token Analyzer is a technical utility designed to provide developers with precise control over their language model interactions. By leveraging the gpt-tokenizer library, it allows users of Openclaw Skills to accurately simulate how a prompt will be broken down by OpenAI-style models before making an API call. This tool is essential for maintaining cost-efficiency and ensuring that complex prompts or retrieved data fit within specific context window constraints.
As a foundational component for those building with Openclaw Skills, this analyzer provides immediate feedback on character counts, token counts, and the density of information within your text. Whether you are building autonomous agents or complex RAG pipelines, having a local method to verify tokenization saves time and prevents avoidable API errors caused by context overflow.
To get started with this tool from the Openclaw Skills collection, first install the necessary tokenizer dependency:
npm install -g gpt-tokenizer
Next, create the executable script by running the following command in your terminal:
cat <<'EOF' > prompt-token
#!/usr/bin/env node
import { encode } from "gpt-tokenizer"
import fs from "fs"
const args = process.argv.slice(2)
if (args.length === 0) {
console.log("Usage:")
console.log(" prompt-token analyze <file>")
console.log(" prompt-token text \"your prompt here\"")
process.exit(1)
}
let text = ""
if (args[0] === "analyze") {
const file = args[1]
if (!file) {
console.error("Missing file path")
process.exit(1)
}
text = fs.readFileSync(file, "utf8")
} else if (args[0] === "text") {
text = args.slice(1).join(" ")
} else {
console.error("Unknown command")
process.exit(1)
}
const tokens = encode(text)
console.log("Prompt Token Analysis")
console.log("---------------------")
console.log("Characters:", text.length)
console.log("Tokens:", tokens.length)
console.log("Average chars/token:", (text.length / tokens.length).toFixed(2))
const estimatedCost = tokens.length / 1000000 * 5
console.log("")
console.log("Estimated cost (example $5 / 1M tokens):")
console.log("$" + estimatedCost.toFixed(6))
EOF
Finally, make the script executable and move it to your system PATH:
chmod +x prompt-token
sudo mv prompt-token /usr/local/bin/
The Prompt Token Analyzer processes text input and generates a structured statistical report. It handles data according to the following schema:
| Attribute | Type | Description |
|---|---|---|
| Input Source | File or String | The raw text to be tokenized. |
| Characters | Integer | The total UTF-8 character count of the input text. |
| Tokens | Integer | The count of tokens after GPT-style encoding. |
| Average Ratio | Float | The efficiency metric (Characters divided by Tokens). |
| Estimated Cost | Float | The financial projection based on a $5/1M token rate. |
Loading
A powerful multi-source aggregator for travel news, destination information, and reviews tailored for tourism professionals.

A sophisticated stock monitoring and alert system designed to provide real-time technical analysis and risk management notifications.

A robust citation engine for automating academic reference formatting, style conversion, and bibliography validation across 1000+ journal standards.

A comprehensive A-share quantitative data tool based on the AkShare library for retrieving market quotes, financial statements, and sector information.

An AI skill that uses Tencent Cloud ArithmeticOCR to recognize and digitize K12 math formulas and equations from images.

A comprehensive modular framework for Chinese long-form novel creation, covering everything from world-building to automated batch text generation.








































