Skip to content

Instantly share code, notes, and snippets.

@sonus
Created July 27, 2025 06:29
Show Gist options
  • Select an option

  • Save sonus/a6488c1553e2a5fa50abdad5845eb4b4 to your computer and use it in GitHub Desktop.

Select an option

Save sonus/a6488c1553e2a5fa50abdad5845eb4b4 to your computer and use it in GitHub Desktop.
Calculating JWT Size
Component Estimated JSON Characters/Bytes Notes
JWT Header (JSON String) ~40 characters Example: {"alg":"HS256","typ":"JWT"}
Fixed Payload Claims (JSON String) ~200 characters iss, exp, iat, userid, email, plus the permissions array structure {"permissions":[]}
Average Permission String Length 10 characters E.g., USER_CREATE
Overhead per Permission in Array ~3 characters For quotes ("") and comma (,) in JSON, i.e., "PERMISSION",
Effective Length per Permission in JSON Payload 13 characters (10 characters for string + 3 characters for overhead)
Base64Url Encoding Overhead ~33% Converts 3 bytes of raw data into 4 Base64 characters
JWT Signature (Encoded) ~43 bytes Fixed size for HS256 algorithm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment