PlayWithJSON

JSON Token Counter

LLM Tokenizer & Cost

Calculate OpenAI, Claude, and Gemini tokens, estimate API costs, and discover minification savings.

Calculated Tokens

Powered by official Tiktoken (o200k / cl100k)

193tokens (OpenAI GPT-4o (o200k))
0.15% of context128,000 limit

Minification Savings: −70 Tokens (36.3%)

Minifying removes whitespace & saves context space before API submission.

Model Comparison & Input Cost

ModelProviderTokensEst. Cost
OpenAI GPT-4o (o200k)OpenAI193$0.000483
OpenAI GPT-4 Turbo (cl100k)OpenAI194$0.00194
Claude 3.5 SonnetAnthropic198$0.000594
Gemini 1.5 FlashGoogle190$0.000014
Meta Llama 3.1 (70B)Meta196$0.000116

Structural Metrics

Characters

644

Words

68

Lines

31

Total Keys

18

Max Depth

6 levels

Char / Token

3.34

JSON Token Counter - Estimate Tokens for OpenAI, Claude, and Gemini

Calculate exact token counts and cost estimates for JSON payloads across OpenAI GPT-4o, Anthropic Claude 3.5 Sonnet, Google Gemini 1.5, and Meta Llama 3 models.

Includes intelligent token reduction analysis showing how many tokens and dollars you can save by minifying JSON before injecting it into system prompts, RAG context windows, or tool calls.

{}

Why Use PlayWithJSON?

  • Multi-model token estimates (GPT-4o, Claude 3.5, Gemini 1.5, Llama 3)
  • Real-time token savings calculation comparing formatted vs minified JSON
  • Context window percentage indicators and cost per request estimations
  • Deep JSON structural metrics (total keys, nested depth, character counts)
  • 100% client-side calculation with zero server telemetry

Key Features of JSON Token Counter

Accurate LLM Tokenization

Calibrated subword byte-pair tokenizer designed specifically for JSON punctuation and syntax.

Minification Savings Analysis

See exactly how many tokens and dollars you save by stripping whitespace before API calls.

Multi-Model Comparison

Side-by-side token and cost metrics across OpenAI, Anthropic, Google, and Meta models.

Structural JSON Metrics

Inspect total key count, max tree depth, character counts, and word counts at a glance.

Context Window Gauge

Visual progress bar displaying how much of the model’s context window your payload consumes.

1-Click Minified Copy

Copy the token-optimized minified JSON directly to your clipboard for your prompts.

How to Count JSON Tokens Online

1

Paste JSON Payload

Paste your prompt JSON, function call schema, or RAG context into the editor.

2

View Token Counts

Instantly view token counts for GPT-4o, Claude 3.5, Gemini 1.5, and Llama 3.

3

Check Token Savings

Review the token difference between formatted and minified JSON.

4

Copy Optimized JSON

Copy the minified JSON to save context space and reduce API invoice costs.

JSON Token Calculation Example

Formatted JSON (185 Tokens)
{ "query": "financial_report", "filters": { "year": 2026, "region": "APAC" } }
Minified JSON (112 Tokens - 39.5% Saved)
1{"query":"financial_report","filters":{"year":2026,"region":"APAC"}}

Token Calculation Rules

Invalid JSON
1{
2 "name": "Report" // trailing comma
3,}
Syntax error: invalid JSON syntax still calculates raw text tokens
Valid JSON Payload
1{
2 "prompt": "Summarize this data",
3 "temperature": 0.7
4}

Supported LLM Architectures

OpenAI GPT-4o and o1 token estimation
Anthropic Claude 3.5 Sonnet / Haiku / Opus
Google Gemini 1.5 Pro & Flash (1M tokens)
Meta Llama 3 & 3.1 open models
Formatted vs minified token delta
Estimated API call cost calculation in USD
JSON key count & depth analytics
Word, character, and line counters
100% private in-browser analysis
Frequently Asked Questions

Frequently Asked Questions about JSON Tokens

In English prose, 1 token is roughly 4 characters. In JSON, structural symbols (curly braces, colons, quotes) are usually 1 token each, making minification especially effective at reducing token counts.

More JSON Developer Tools

View All Tools

JSON Formatter

Format, validate and inspect JSON data

JSON5 Formatter

Format and validate JSON5 with comments

JSON ↔ JSON5

Convert between JSON and modern JSON5

JSON to TypeScript

Generate TypeScript interfaces from JSON

JSON to Zod

Generate Zod schemas from JSON

Text to JSON

Convert text and schemas into structured JSON

JSON Sorter Online

Sort JSON keys alphabetically and order arrays

JWT Decoder Online

Decode JWT header, payload and expiration

JSON Stringify Online

Escape quotes and stringify or unescape JSON

Mock JSON Generator

Generate realistic mock data for APIs and testing

JSON to CSV

Export structured JSON arrays into CSV spreadsheets

JSONPath Tester

Query and filter JSON data with path expressions

JSON Schema Generator

Generate JSON Schema from sample JSON

JSON Diff & Compare

Compare two JSON objects and find differences

JSON ↔ YAML

Convert JSON/JSON5 to YAML and back with comments

JSON ↔ XML

Convert JSON to XML and XML to JSON with attributes

YAML to CSV

Convert YAML lists and objects into spreadsheets

CSV to JSON / JSON5

Convert CSV/TSV to JSON or JSON5 with type parsing

JSON to BigQuery

Generate BigQuery Schema JSON and CREATE TABLE DDL

JSON to GraphQL

Generate GraphQL SDL types, queries, and inputs

JSON to MySQL

Generate MySQL CREATE TABLE DDL and INSERT queries

JSON to PostgreSQL

Generate PostgreSQL CREATE TABLE DDL, JSONB and INSERTs

JSON Flattener

Flatten nested JSON to dot notation or unflatten back

JSON Tree Visualizer

Interactive SVG mindmap graph and collapsible node tree

JSON Minifier Online

Compact and compress JSON by stripping whitespace

JSON Token Counter

Calculate LLM tokens (GPT-4o, Claude) and API costs

Broken JSON Repair

Automatically heal broken and truncated AI/LLM JSON