TokenSave logo TokenSave

TokenSave Data · Dataset

Python vs Java vs Go vs C: how many tokens the same code costs

The same two programs cost 809 GPT tokens in Python and 1,536 in C (+90%). Python and Ruby were the cheapest languages on every tokenizer we tested; Go and C were the most expensive. Claude 5.5 needed 43% to 59% more tokens than GPT for the same code.

Measured 2026-10-18 · 10 languages · 2 programs · 4 tokenizers · License CC BY 4.0 · Related: token cost by data format

DOI 10.5281/zenodo.23446563 · Also on Hugging Face · Kaggle · GitHub

Tokens for the same two programs in 10 programming languages on Claude, Gemini and GPT

Key findings

All 10 languages

Tokens for both programs together, with the difference versus Python on the same tokenizer in brackets. Per-program counts are in the CSV.

LanguageLinesClaude Opus/Sonnet 5.5Claude Haiku 4.5Gemini 3.xGPT o200k
Python1071,176 (±0%)970 (±0%)963 (±0%)809 (±0%)
Ruby1091,181 (±0%)961 (-1%)944 (-2%)819 (+1%)
JavaScript1261,442 (+23%)1,199 (+24%)1,184 (+23%)967 (+20%)
TypeScript1271,590 (+35%)1,311 (+35%)1,288 (+34%)1,070 (+32%)
PHP1391,609 (+37%)1,311 (+35%)1,262 (+31%)1,128 (+39%)
Rust1421,815 (+54%)1,452 (+50%)1,411 (+47%)1,189 (+47%)
Java1541,934 (+64%)1,551 (+60%)1,511 (+57%)1,217 (+50%)
C++1721,933 (+64%)1,626 (+68%)1,617 (+68%)1,343 (+66%)
Go1992,143 (+82%)1,749 (+80%)1,701 (+77%)1,359 (+68%)
C1772,219 (+89%)1,859 (+92%)1,820 (+89%)1,536 (+90%)

Method

Limitations

How to cite

Free to use, quote and republish with attribution under CC BY 4.0. Please link to this page.

TokenSave (2026). Token cost by programming language: the same programs in 10 languages on Claude, Gemini and GPT [Data set]. Zenodo. https://doi.org/10.5281/zenodo.23446563

Embed the chart

Related

Questions or corrections: contact@jonhisking.com