Skip to main content
Regexflux

JWT Token

intermediate

Matches JSON Web Token strings in header.payload.signature format.

jwttokensecurityauthentication

Pattern

/eyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]+/g

Try It

0 of 4 strings matched

Explanation

Matches JWT format: three base64url-encoded segments separated by dots. JWTs always start with 'eyJ' (base64 for '{"') in both header and payload.

Test Strings

Matching

  • eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U

Non-matching

  • not.a.jwt
  • eyJ.short.token
  • random-string

Language Compatibility

LanguageSupport
JSFull support
PYTHONFull support
JAVAFull support
PHPFull support
GOFull support

Code Snippets

const regex = /eyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]+/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);

Related Patterns