ROI Calculator & Analysis β
The ROI Calculator and Analysis tools help you understand the real dollar savings from token optimization. Convert "30% savings" into concrete cost projections, export reports for stakeholders, and visualize savings with beautiful terminal dashboards.
Why ROI Calculator? β
- Marketing Gold: Show actual $ amounts instead of percentages
- Visual Dashboard: Beautiful terminal UI with React/Ink
- Multiple Export Formats: JSON, Markdown, CSV for any workflow
- Multi-Currency Support: USD, EUR, GBP, JPY, CHF, CAD, AUD
- Zero Maintenance: Pure math, no external dependencies
- CI/CD Ready: Perfect for GitHub Actions and automation
What's New in v1.0.0 β
π¨ Visual Dashboard - React-powered terminal UI with:
- Rainbow gradient header
- Animated progress bars
- Cost comparison tables
- Real-time recommendations
π Multiple Output Formats:
--format json- Machine-readable for CI/CD--format markdown- GitHub PR comments, documentation--format csv- Excel/Google Sheets--visual- Beautiful terminal dashboard
π± Multi-Currency Support:
- Convert costs to 7 major currencies
- Custom exchange rates
- Smart formatting (JPY without decimals, etc.)
Installation β
No additional installation needed - included with tonl-mcp-bridge:
npm install -g tonl-mcp-bridgeQuick Start β
Analyze a File with Visual Dashboard β
tonl analyze data.json --visualOutput:
ββ¦β βββ βββ β¦
β β β βββ β
β© βββ βββ β©ββ
ROI Analyzer v1.0.0
π Token Usage Analysis
data.json
JSON ββββββββββββββββββββββββββββββββββββββββ 477 tokens
TONL ββββββββββββββββββββββββββββββββββββββββ 255 tokens (-46.5% β
)
π° Cost Analysis (GPT-4o (OpenAI))
Per 1K Per 1M
ββββββββββββββββββββββββββββββββββββββββββββββββββ
JSON $1.19 $1,192.50
TONL $0.64 $637.50
ββββββββββββββββββββββββββββββββββββββββββββββββββ
π NET SAVINGS $0.55 $555.00
π‘ Annual Savings @ 1K requests/day:
$202.57/year
β
Recommendation: STRONGLY USE TONLExport to Markdown for GitHub β
tonl analyze data.json --format markdown > report.mdCreates a beautiful markdown report:
# π TONL ROI Analysis Report
## π Analysis Summary
- **File:** `data.json`
- **Model:** GPT-4o (OpenAI)
- **Savings:** 46.5%
## π° Cost Analysis
| Metric | JSON | TONL | Savings |
|--------|------|------|----------|
| Per 1M requests | $1,192.50 | $637.50 | **$555.00** |
### π $202.57 per year savings @ 1K requests/day
β
Recommendation: **STRONGLY USE TONL**Multi-Currency Analysis β
# Convert to EUR
tonl analyze data.json --currency EUR --visual
# Custom exchange rate
tonl analyze data.json --currency EUR --rate 0.95
# Export CSV in GBP
tonl analyze data.json --currency GBP --export results.csvCLI Commands β
tonl analyze - File Analysis β
Analyze actual JSON files to calculate token savings:
# Basic analysis
tonl analyze data.json
# Visual dashboard
tonl analyze data.json --visual
# Different output formats
tonl analyze data.json --format json
tonl analyze data.json --format markdown
tonl analyze data.json --format csv
# Multi-currency
tonl analyze data.json --currency EUR
tonl analyze data.json --currency JPY
# Export to file
tonl analyze data.json --export report.csv
tonl analyze data.json --format markdown > report.md
# Batch analysis
tonl analyze data/*.json --format csv
# Different models
tonl analyze data.json --model claude-3.5-sonnet --visualOptions:
-m, --model <model>- LLM model (gpt-4o, claude-3.5-sonnet, gemini-2.0-flash)-f, --format <type>- Output format (text|json|markdown|csv)-c, --currency <code>- Currency (USD, EUR, GBP, JPY, CHF, CAD, AUD)-r, --rate <number>- Custom exchange rate--visual- Show visual dashboard UI--export <file>- Export to CSV file--summary- Show business impact summary--list-models- List available models
tonl roi - ROI Calculator β
Calculate projected savings from percentages:
# Calculate from savings percentage
tonl roi --savings 45 --queries-per-day 1000 --model gpt-4o
# With exact token counts
tonl roi \
--tokens-before 1500 \
--tokens-after 750 \
--queries-per-day 5000 \
--model claude-sonnet-4
# JSON output
tonl roi --savings 50 --queries-per-day 2000 --json
# Marketing summary
tonl roi --savings 60 --queries-per-day 10000 --summaryOptions:
-b, --tokens-before <n>- Tokens before optimization-a, --tokens-after <n>- Tokens after optimization-s, --savings <n>- Savings percentage (e.g., 45 for 45%)-q, --queries-per-day <n>- Number of queries per day-m, --model <model>- LLM model--json- Output as JSON--summary- Show marketing summary--list-models- List available models
Output Formats β
Text (Default) β
Human-readable output for terminal:
tonl analyze data.jsonJSON β
Machine-readable for automation:
tonl analyze data.json --format json > results.json[
{
"model": {"name": "GPT-4o", "provider": "OpenAI"},
"jsonTokens": 477,
"tonlTokens": 255,
"savingsPercent": 46.5,
"costs": {
"json": {"per1M": 1192.5},
"tonl": {"per1M": 637.5},
"savings": {"per1M": 555}
}
}
]Markdown β
Perfect for documentation and GitHub:
tonl analyze data.json --format markdown > ANALYSIS.mdUse cases:
- GitHub PR comments
- Documentation sites
- Wiki pages
- Confluence/Notion
CSV (Smart Enterprise Format) β
12-column format optimized for business reporting:
tonl analyze data.json --format csv > report.csv
tonl analyze data.json --export report.csvColumns:
- Context (4): Timestamp, File, Model, Currency
- Hard Facts (5): Original Tokens, TONL Tokens, Savings %, Cost per 1K (JSON), Cost per 1K (TONL)
- Money Shot (3): Net Savings per 1M, Annual Savings @ 1K/day, Recommendation
Perfect for:
- Executive dashboards
- Budget planning
- Board presentations
- CFO reports
Visual Dashboard β
The --visual flag activates a beautiful React-powered terminal UI:
Features:
- π Rainbow gradient header
- π Animated progress bars for token comparison
- π° Clean cost tables
- β Color-coded recommendations
- π Real-time updates
When to use:
- Live demos
- Sales presentations
- Team showcases
- "Wow factor" moments
Example:
# Single file
tonl analyze products.json --visual
# With currency
tonl analyze data.json --currency EUR --visual
# Different model
tonl analyze data.json --model claude-3.5-sonnet --visualMulti-Currency Support β
Supported currencies:
- πΊπΈ USD - US Dollar (default)
- πͺπΊ EUR - Euro
- π¬π§ GBP - British Pound
- π―π΅ JPY - Japanese Yen
- π¨π CHF - Swiss Franc
- π¨π¦ CAD - Canadian Dollar
- π¦πΊ AUD - Australian Dollar
Usage:
# Default rates (updated regularly)
tonl analyze data.json --currency EUR
# Custom exchange rate
tonl analyze data.json --currency GBP --rate 0.79
# Visual dashboard in JPY
tonl analyze data.json --currency JPY --visual
# CSV export in CHF
tonl analyze data.json --currency CHF --export swiss-report.csvSmart Formatting:
- JPY: No decimal places (Β₯1,193 instead of Β₯1,192.50)
- Other currencies: 2 decimal places
- Currency symbols: $, β¬, Β£, Β₯, CHF, CA$, A$
Supported LLM Models β
OpenAI β
- gpt-4o: $2.50/1M tokens
- gpt-4o-mini: $0.15/1M tokens
- gpt-4-turbo: $10.00/1M tokens
- o1: $15.00/1M tokens
- o1-mini: $3.00/1M tokens
Anthropic β
- claude-opus-4: $15.00/1M tokens
- claude-sonnet-4: $3.00/1M tokens
- claude-sonnet-3.5: $3.00/1M tokens
- claude-haiku-4: $0.25/1M tokens
Google β
- gemini-2.0-flash: $0.075/1M tokens
- gemini-1.5-pro: $1.25/1M tokens
- gemini-1.5-flash: $0.075/1M tokens
Pricing as of December 2024
CI/CD Integration β
GitHub Actions β
Post analysis to PR comments:
name: TONL Analysis
on: [pull_request]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install TONL
run: npm install -g tonl-mcp-bridge
- name: Analyze Changes
run: |
tonl analyze data/*.json --format markdown > analysis.md
- name: Comment PR
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const analysis = fs.readFileSync('analysis.md', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: analysis
});GitLab CI β
tonl-analysis:
stage: test
script:
- npm install -g tonl-mcp-bridge
- tonl analyze data/*.json --format markdown > analysis.md
artifacts:
paths:
- analysis.mdJenkins β
stage('TONL Analysis') {
steps {
sh 'npm install -g tonl-mcp-bridge'
sh 'tonl analyze data/*.json --format csv > report.csv'
archiveArtifacts artifacts: 'report.csv'
}
}Real-World Examples β
Example 1: E-Commerce Product Search β
tonl analyze products.json --visualScenario: 5,000 product searches/day Result: $6,862/year savings with GPT-4o
Example 2: Customer Support Bot β
tonl analyze faqs.json \
--model gpt-4o-mini \
--format markdown > support-analysis.mdScenario: 10,000 FAQ queries/day Result: $329/year savings
Example 3: Enterprise RAG β
tonl analyze documents/*.json \
--model claude-sonnet-4 \
--currency EUR \
--export enterprise-report.csvScenario: 50,000 document queries/day Result: β¬45,000/year savings
Example 4: Batch Analysis for Report β
# Analyze all data files
tonl analyze data/*.json --format csv > monthly-report.csv
# Generate markdown summary
tonl analyze data/*.json --format markdown > README.mdProgrammatic Usage β
import {
calculateROI,
formatROI,
exportToCSV,
listLLMModels
} from 'tonl-mcp-bridge/cli/commands/roi-calculator';
import { formatAsMarkdown, formatAsJSON } from 'tonl-mcp-bridge/cli/commands/formatters';
// Calculate ROI
const roi = calculateROI(1000, 550, 'gpt-4o');
// Format as markdown
const markdown = formatAsMarkdown([roi], 'USD');
fs.writeFileSync('report.md', markdown);
// Export to CSV
const csv = exportToCSV([roi], 'EUR', 0.92);
fs.writeFileSync('report.csv', csv);
// JSON output
const json = formatAsJSON([roi]);
console.log(json);Best Practices β
1. Use Visual Dashboard for Demos β
# Sales presentation
tonl analyze demo-data.json --visual
# Team showcase
tonl analyze production-sample.json --currency EUR --visual2. Automate Reports β
# Daily analysis
tonl analyze logs/*.json --format csv > "daily-$(date +%Y-%m-%d).csv"
# Weekly markdown report
tonl analyze data/*.json --format markdown > weekly-report.md3. Multi-Format Export β
# CSV for Excel
tonl analyze data.json --export financial.csv
# Markdown for docs
tonl analyze data.json --format markdown > SAVINGS.md
# JSON for automation
tonl analyze data.json --format json > metrics.json4. Currency for Global Teams β
# US team
tonl analyze data.json --currency USD --export us-report.csv
# EU team
tonl analyze data.json --currency EUR --export eu-report.csv
# APAC team
tonl analyze data.json --currency JPY --export jp-report.csvTroubleshooting β
File Not Found β
# β Typo
tonl analyze dat.json
# β
Shows suggestions
β Error: File not found: dat.json
Did you mean:
β’ data.json
Try: tonl analyze --helpInvalid JSON β
# β Malformed JSON
tonl analyze broken.json
# β
Helpful error message
β Error: Invalid JSON in broken.json
Error near position 42
Unexpected token } in JSON at position 42
Common issues:
β’ Missing quotes around strings
β’ Trailing commas in objects/arrays
β’ Unescaped special characters
Tip: Validate your JSON at https://jsonlint.comUnknown Format β
# β Invalid format
tonl analyze data.json --format yaml
# β
Use valid format
tonl analyze data.json --format markdown
# Valid: text, json, markdown, csvNext Steps β
- CLI Reference - Complete command documentation
- Examples - More real-world scenarios
- MongoDB Guide - Use with real query data
- Token Savings - Understanding the math