Tokens & Context Windows Cheat Sheet
What counts, what it costs, and what falls out of the window
Tokens are the unit of both billing and memory. Estimating them well is most of cost control and all of context management.
Estimating tokens
| Content | Rough tokens | Note |
|---|---|---|
| English prose | ~1 token per 4 characters | About 0.75 tokens per word |
| Code | ~1 token per 3 characters | Punctuation and indentation are dense |
| JSON | Higher still | Braces, quotes and keys all cost |
| Non-Latin scripts | 2–3× more per character | Budget generously for CJK and Arabic |
| An A4 page of text | ~500–700 tokens | Useful for sizing document pipelines |
What occupies the window
- The system prompt — every single turn It is re-sent with each request, not remembered
- The full message history you choose to send The API is stateless; you own the memory
- Tool and function definitions Their JSON schemas are prompt text
- Tool results fed back in Often the largest single contributor
- The reply being generated Input and output share the window
Truncation strategies
| Strategy | Keeps | Loses |
|---|---|---|
| Sliding window | The last N turns | Anything agreed early on |
| Summarise-and-drop | A rolling summary plus recent turns | Detail, gradually |
| Pinned + recent | Explicitly marked turns, plus recent | Needs someone to choose the pins |
| Retrieval over history | Whatever matches the current turn | Continuity between turns |
Frequently asked questions
Does a bigger context window mean I can stop managing context?
No. Cost scales with what you send, latency grows with it, and retrieval accuracy over a very long context is not uniform. A big window buys headroom, not a free pass.
Why does my token count differ from my word count?
Tokens are sub-word pieces. English prose runs about 0.75 tokens per word; code, JSON and non-Latin scripts run considerably higher because punctuation and rare characters split into more pieces.
Was this cheat sheet useful?
Comments
No comments yet — be the first.
Keep going
Browse all
More cheat sheets
Need a different cheat sheet?
Tell us what you would like to see and we will build it — free.
Request a cheat sheet