Sobes.tech
Junior — Middle

What is the structure of a JSON Web Token and what are its parts?

sobes.tech AI

Answer from AI

JSON Web Token (JWT) consists of three parts separated by dots:

  1. Header — contains information about the token type (usually "JWT") and the signing algorithm (e.g., HS256).
  2. Payload — contains claims, which are the data transmitted, such as user ID, expiration time, etc.
  3. Signature — created by encoding the header and payload and signing them with a secret key or private key.

Example JWT:

xxxxx.yyyyy.zzzzz

where:

  • xxxxx — base64url-encoded Header
  • yyyyy — base64url-encoded Payload
  • zzzzz — base64url-encoded signature

This format allows secure transmission of information between parties and verification of its authenticity.