Skip to content

Instantly share code, notes, and snippets.

@cometkim
Last active April 22, 2026 09:30
Show Gist options
  • Select an option

  • Save cometkim/f5b382e9f69b3a35513ce66725b0e42e to your computer and use it in GitHub Desktop.

Select an option

Save cometkim/f5b382e9f69b3a35513ce66725b0e42e to your computer and use it in GitHub Desktop.
Token count change due to Claude's tokenizer update

Token counting: claude-opus-4-6 vs claude-opus-4-7

Generated: 2026-04-16 15:39:30 UTC

Both columns come from the real /v1/messages/count_tokens endpoint.

Summary by category

Category claude-opus-4-6 claude-opus-4-7 Ratio
Text 211 324 1.54x
CJK 194 233 1.20x
Math 200 244 1.22x
Symbols 196 237 1.21x
System 33 55 1.67x
Tools 4098 5554 1.36x
Images 15500 26971 1.74x

Text

Test claude-opus-4-6 claude-opus-4-7 Δ Ratio
Single word: "hi" 8 13 +5 1.62x
Short message: "Hello, Claude" 10 18 +8 1.80x
Longer sentence (10x pangram) 118 192 +74 1.63x
Multi-turn (3 messages) 35 44 +9 1.26x
Code block (Python) 40 57 +17 1.43x

CJK

Test claude-opus-4-6 claude-opus-4-7 Δ Ratio
Korean: 안녕하세요 14 18 +4 1.29x
Korean sentence 43 47 +4 1.09x
Japanese: こんにちは 12 16 +4 1.33x
Japanese sentence 43 47 +4 1.09x
Chinese: 你好世界 12 16 +4 1.33x
Chinese sentence 37 41 +4 1.11x
Mixed CJK + English 33 48 +15 1.45x

Math

Test claude-opus-4-6 claude-opus-4-7 Δ Ratio
LaTeX inline 31 41 +10 1.32x
LaTeX display 38 51 +13 1.34x
Unicode math symbols 72 77 +5 1.07x
Equation-heavy plain 59 75 +16 1.27x

Symbols

Test claude-opus-4-6 claude-opus-4-7 Δ Ratio
Emoji with ZWJ 58 71 +13 1.22x
Arabic (RTL) 30 34 +4 1.13x
Hebrew (RTL) 23 27 +4 1.17x
Cyrillic 25 29 +4 1.16x
Whitespace stress 21 28 +7 1.33x
URLs and emails 39 48 +9 1.23x

System

Test claude-opus-4-6 claude-opus-4-7 Δ Ratio
With system prompt 15 25 +10 1.67x
System (block array) 18 30 +12 1.67x

Tools

Test claude-opus-4-6 claude-opus-4-7 Δ Ratio
1 minimal tool 527 716 +189 1.36x
2 minimal tools 549 744 +195 1.36x
3 minimal tools 571 772 +201 1.35x
1 tool (get_weather) 566 765 +199 1.35x
2 tools (weather+time) 603 811 +208 1.34x
tool_choice=any, 1 tool 619 845 +226 1.37x
tool_choice=any, 3 tools 663 901 +238 1.36x

Images

Test claude-opus-4-6 claude-opus-4-7 Δ Ratio
PNG 200x200 76 81 +5 1.07x
PNG 500x500 336 341 +5 1.01x
PNG 1000x500 660 665 +5 1.01x
PNG 1000x1000 1308 1313 +5 1.00x
PNG 1092x1092 1533 1538 +5 1.00x
PNG 1568x784 1580 1585 +5 1.00x
PNG 784x1568 1580 1585 +5 1.00x
PNG 1568x1568 1533 3153 +1620 2.06x
PNG 2000x1500 1576 3905 +2329 2.48x
PNG 3000x2000 1548 4721 +3173 3.05x
JPEG 800x600 650 655 +5 1.01x
JPEG 1920x1080 1572 2708 +1136 1.72x
JPEG 3000x2000 1548 4721 +3173 3.05x

Large-corpus token counting: claude-opus-4-6 vs claude-opus-4-7

Generated: 2026-04-16 16:03:04 UTC

Both columns come from the real /v1/messages/count_tokens endpoint. tok/char = tokens / source characters. ratio = opus-4-7 / opus-4-6.

Aggregate ratios by category

Category Total 4.6 Total 4.7 Overall ratio Tests
Docs / Website 129,888 168,849 1.300x 9
Source code 131,734 170,320 1.293x 13
Books (prose) 102,120 136,321 1.335x 9
CJK 337,826 360,899 1.068x 12
Hebrew (RTL) 104,641 115,284 1.102x 6
Agentic 4,444 5,821 1.310x 1

Docs / Website

Test Chars 4.6 4.7 tok/char (4.6) tok/char (4.7) Ratio
wikipedia_transformer.txt [5K] 5,000 1650 2172 0.330 0.434 1.316x
wikipedia_transformer.txt [25K] 25,000 8156 10740 0.326 0.430 1.317x
wikipedia_transformer.txt [100K] 100,000 31939 41979 0.319 0.420 1.314x
wikipedia_tokyo.txt [5K] 5,000 1664 2409 0.333 0.482 1.448x
wikipedia_tokyo.txt [25K] 25,000 8710 11811 0.348 0.472 1.356x
wikipedia_tokyo.txt [100K] 100,000 36094 48598 0.361 0.486 1.346x
mdn_fetch.html [5K] 5,000 1638 2063 0.328 0.413 1.259x
mdn_fetch.html [25K] 25,000 8203 10020 0.328 0.401 1.222x
mdn_fetch.html [100K] 100,000 31834 39057 0.318 0.391 1.227x

Source code

Test Chars 4.6 4.7 tok/char (4.6) tok/char (4.7) Ratio
cpython_asyncio.py [5K] 5,000 1476 1935 0.295 0.387 1.311x
cpython_asyncio.py [25K] 25,000 6641 8497 0.266 0.340 1.279x
cpython_asyncio.py [full 76K] 76,247 19131 24724 0.251 0.324 1.292x
react_scheduler.js [5K] 5,000 1550 2197 0.310 0.439 1.417x
react_scheduler.js [full 18K] 18,260 5516 7553 0.302 0.414 1.369x
linux_sched_core.c [5K] 5,000 2077 2702 0.415 0.540 1.301x
linux_sched_core.c [25K] 25,000 10284 12863 0.411 0.515 1.251x
linux_sched_core.c [100K] 100,000 39458 49692 0.395 0.497 1.259x
rust_iter_mod.rs [5K] 5,000 1492 2056 0.298 0.411 1.378x
rust_iter_mod.rs [full 8K] 8,287 2565 3457 0.310 0.417 1.348x
go_http_server.go [5K] 5,000 1396 1877 0.279 0.375 1.345x
go_http_server.go [25K] 25,000 7636 10093 0.305 0.404 1.322x
go_http_server.go [100K] 100,000 32512 42674 0.325 0.427 1.313x

Books (prose)

Test Chars 4.6 4.7 tok/char (4.6) tok/char (4.7) Ratio
alice_in_wonderland.txt [5K] 5,000 1339 1901 0.268 0.380 1.420x
alice_in_wonderland.txt [25K] 25,000 6718 8927 0.269 0.357 1.329x
alice_in_wonderland.txt [100K] 100,000 27407 36291 0.274 0.363 1.324x
pride_and_prejudice.txt [5K] 5,000 1177 1600 0.235 0.320 1.359x
pride_and_prejudice.txt [25K] 25,000 6228 8362 0.249 0.334 1.343x
pride_and_prejudice.txt [100K] 100,000 25157 33659 0.252 0.337 1.338x
the_odyssey.txt [5K] 5,000 1302 1791 0.260 0.358 1.376x
the_odyssey.txt [25K] 25,000 6349 8473 0.254 0.339 1.335x
the_odyssey.txt [100K] 100,000 26443 35317 0.264 0.353 1.336x

CJK

Test Chars 4.6 4.7 tok/char (4.6) tok/char (4.7) Ratio
wiki_zh_ai.txt [5K] 5,000 3308 3768 0.662 0.754 1.139x
wiki_zh_ai.txt [25K] 25,000 15727 18321 0.629 0.733 1.165x
wiki_zh_ai.txt [full 79K] 79,473 42872 51122 0.539 0.643 1.192x
wiki_ja_ml.txt [5K] 5,000 3156 3552 0.631 0.710 1.125x
wiki_ja_ml.txt [25K] 25,000 15470 17462 0.619 0.698 1.129x
wiki_ja_ml.txt [full 47K] 47,345 28452 32604 0.601 0.689 1.146x
wiki_ko_ai.txt [5K] 5,000 4035 4312 0.807 0.862 1.069x
wiki_ko_ai.txt [25K] 25,000 18076 19684 0.723 0.787 1.089x
wiki_ko_ai.txt [full 50K] 50,919 37968 41099 0.746 0.807 1.082x
three_kingdoms_zh.txt [5K] 5,000 5756 5827 1.151 1.165 1.012x
three_kingdoms_zh.txt [25K] 25,000 32201 32272 1.288 1.291 1.002x
three_kingdoms_zh.txt [100K] 100,000 130805 130876 1.308 1.309 1.001x

Hebrew (RTL)

Test Chars 4.6 4.7 tok/char (4.6) tok/char (4.7) Ratio
wiki_he_ai.txt [5K] 5,000 2739 2992 0.548 0.598 1.092x
wiki_he_ai.txt [25K] 25,000 12585 14164 0.503 0.567 1.125x
wiki_he_ai.txt [100K] 100,000 50815 56635 0.508 0.566 1.115x
wiki_he_tokyo.txt [5K] 5,000 3409 3705 0.682 0.741 1.087x
wiki_he_tokyo.txt [25K] 25,000 16881 18171 0.675 0.727 1.076x
wiki_he_tokyo.txt [full 26K] 26,967 18212 19617 0.675 0.727 1.077x

Agentic

Test Chars 4.6 4.7 tok/char (4.6) tok/char (4.7) Ratio
Agentic session w/ tools+thinking 4444 5821 1.310x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment