Base64 URL EncodingΒΆ

JWT tokens are serialized using Base64 URL encoding.

IdentityModel includes the Base64Url class to help with encoding/decoding:

var text = "hello";
var b64url = Base64Url.Encode(text);

text = Base64Url.Decode(b64url);

Note

ASP.NET Core has built-in support via WebEncoders.Base64UrlEncode and WebEncoders.Base64UrlDecode.