Regex for JSON Web Token

/\beyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*/g

Options
Matches

Examples

Note

A JWT’s header and payload are Base64url JSON, which always starts with eyJ. Paste one into the JWT Decoder to read it.

Matches in the example

  • "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.c2lnbmF0dXJl"

Token by token

  1. \b a word boundary
  2. eyJ the text “eyJ”
  3. [A-Za-z0-9_-]+ one of: “A” to “Z”, “a” to “z”, “0” to “9”, “_” or “-”, one or more times, as many as possible
  4. \. the character “.”
  5. eyJ the text “eyJ”
  6. [A-Za-z0-9_-]+ one of: “A” to “Z”, “a” to “z”, “0” to “9”, “_” or “-”, one or more times, as many as possible
  7. \. the character “.”
  8. [A-Za-z0-9_-]* one of: “A” to “Z”, “a” to “z”, “0” to “9”, “_” or “-”, zero or more times, as many as possible

Other patterns