#### [Abblix\.Utils](https://www.abblix.com/en/docs/api/abblix-utils 'index')
### [System\.Buffers\.Text](https://www.abblix.com/en/docs/api/abblix-utils/System.Buffers.Text 'System\.Buffers\.Text')

## Base64Url Class

Polyfill of the BCL [Base64Url](https://www.abblix.com/en/docs/api/abblix-utils/System.Buffers.Text.Base64Url 'System\.Buffers\.Text\.Base64Url') shipping in net9\.0\+, providing strict RFC 7515 §3
\(and RFC 4648 §5\) base64url decoding/encoding without padding for the net8\.0 target\. The
shape mirrors the BCL surface so consumer code references `System.Buffers.Text.Base64Url`
uniformly across all TFMs we ship to\. Removed in the same commit that drops the net8\.0 target
after net8\.0 reaches end\-of\-life on 2026\-11\-10\.

```csharp
public static class Base64Url
```

Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → Base64Url
### Methods

## Base64Url\.DecodeFromChars\(ReadOnlySpan\<char\>\) Method {#System.Buffers.Text.Base64Url.DecodeFromChars(System.ReadOnlySpan_char_)}

Decodes a base64url\-encoded character span into a byte array\. Strict per RFC 7515 §3:
rejects characters outside the alphabet `A-Z a-z 0-9 - _`, rejects standard\-base64
alphabet characters `+` and `/`, rejects padding `=`, and rejects inputs
whose length leaves `length mod 4 == 1`\.

```csharp
public static byte[] DecodeFromChars(System.ReadOnlySpan<char> source);
```
#### Parameters

###### `source` [System\.ReadOnlySpan&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1 'System\.ReadOnlySpan\`1')[System\.Char](https://learn.microsoft.com/en-us/dotnet/api/system.char 'System\.Char')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1 'System\.ReadOnlySpan\`1') {#System.Buffers.Text.Base64Url.DecodeFromChars(System.ReadOnlySpan_char_).source}

The base64url\-encoded characters\.

#### Returns
[System\.Byte](https://learn.microsoft.com/en-us/dotnet/api/system.byte 'System\.Byte')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array')  
The decoded bytes; an empty array when [source](https://www.abblix.com/en/docs/api/abblix-utils/System.Buffers.Text.Base64Url#System.Buffers.Text.Base64Url.DecodeFromChars(System.ReadOnlySpan_char_).source 'System\.Buffers\.Text\.Base64Url\.DecodeFromChars\(System\.ReadOnlySpan\<char\>\)\.source') is empty\.

#### Exceptions

[System\.FormatException](https://learn.microsoft.com/en-us/dotnet/api/system.formatexception 'System\.FormatException')  
Thrown when [source](https://www.abblix.com/en/docs/api/abblix-utils/System.Buffers.Text.Base64Url#System.Buffers.Text.Base64Url.DecodeFromChars(System.ReadOnlySpan_char_).source 'System\.Buffers\.Text\.Base64Url\.DecodeFromChars\(System\.ReadOnlySpan\<char\>\)\.source') contains a
            character outside the base64url alphabet, or when its length leaves a 1\-character
            remainder modulo 4\.

## Base64Url\.EncodeToString\(ReadOnlySpan\<byte\>\) Method {#System.Buffers.Text.Base64Url.EncodeToString(System.ReadOnlySpan_byte_)}

Encodes a byte span as a base64url string per RFC 7515 §3, without trailing padding\.
Replaces standard\-base64 `+` with `-` and `/` with `_`\.

```csharp
public static string EncodeToString(System.ReadOnlySpan<byte> source);
```
#### Parameters

###### `source` [System\.ReadOnlySpan&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1 'System\.ReadOnlySpan\`1')[System\.Byte](https://learn.microsoft.com/en-us/dotnet/api/system.byte 'System\.Byte')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1 'System\.ReadOnlySpan\`1') {#System.Buffers.Text.Base64Url.EncodeToString(System.ReadOnlySpan_byte_).source}

The bytes to encode\.

#### Returns
[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')  
The base64url\-encoded string; [System\.String\.Empty](https://learn.microsoft.com/en-us/dotnet/api/system.string.empty 'System\.String\.Empty') when
            [source](https://www.abblix.com/en/docs/api/abblix-utils/System.Buffers.Text.Base64Url#System.Buffers.Text.Base64Url.EncodeToString(System.ReadOnlySpan_byte_).source 'System\.Buffers\.Text\.Base64Url\.EncodeToString\(System\.ReadOnlySpan\<byte\>\)\.source') is empty\.

## Base64Url\.TryDecodeFromChars\(ReadOnlySpan\<char\>, Span\<byte\>, int\) Method {#System.Buffers.Text.Base64Url.TryDecodeFromChars(System.ReadOnlySpan_char_,System.Span_byte_,int)}

Decodes a base64url\-encoded character span into [destination](https://www.abblix.com/en/docs/api/abblix-utils/System.Buffers.Text.Base64Url#System.Buffers.Text.Base64Url.TryDecodeFromChars(System.ReadOnlySpan_char_,System.Span_byte_,int).destination 'System\.Buffers\.Text\.Base64Url\.TryDecodeFromChars\(System\.ReadOnlySpan\<char\>, System\.Span\<byte\>, int\)\.destination')\.
Mirrors the \.NET 9\+ BCL surface so consumer code can use a single call shape
across TFMs\. Returns `false` when [destination](https://www.abblix.com/en/docs/api/abblix-utils/System.Buffers.Text.Base64Url#System.Buffers.Text.Base64Url.TryDecodeFromChars(System.ReadOnlySpan_char_,System.Span_byte_,int).destination 'System\.Buffers\.Text\.Base64Url\.TryDecodeFromChars\(System\.ReadOnlySpan\<char\>, System\.Span\<byte\>, int\)\.destination') is too
small to hold the decoded bytes; throws [System\.FormatException](https://learn.microsoft.com/en-us/dotnet/api/system.formatexception 'System\.FormatException') on
invalid characters or length\-mod\-4\-of\-1 inputs, matching BCL semantics \-
the "Try" prefix here covers buffer\-size failures, not malformed input\.

```csharp
public static bool TryDecodeFromChars(System.ReadOnlySpan<char> source, System.Span<byte> destination, out int bytesWritten);
```
#### Parameters

###### `source` [System\.ReadOnlySpan&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1 'System\.ReadOnlySpan\`1')[System\.Char](https://learn.microsoft.com/en-us/dotnet/api/system.char 'System\.Char')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1 'System\.ReadOnlySpan\`1') {#System.Buffers.Text.Base64Url.TryDecodeFromChars(System.ReadOnlySpan_char_,System.Span_byte_,int).source}

The base64url\-encoded characters\.

###### `destination` [System\.Span&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.span-1 'System\.Span\`1')[System\.Byte](https://learn.microsoft.com/en-us/dotnet/api/system.byte 'System\.Byte')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.span-1 'System\.Span\`1') {#System.Buffers.Text.Base64Url.TryDecodeFromChars(System.ReadOnlySpan_char_,System.Span_byte_,int).destination}

Buffer to receive the decoded bytes\.

###### `bytesWritten` [System\.Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32 'System\.Int32') {#System.Buffers.Text.Base64Url.TryDecodeFromChars(System.ReadOnlySpan_char_,System.Span_byte_,int).bytesWritten}

On success, the number of bytes written into
            [destination](https://www.abblix.com/en/docs/api/abblix-utils/System.Buffers.Text.Base64Url#System.Buffers.Text.Base64Url.TryDecodeFromChars(System.ReadOnlySpan_char_,System.Span_byte_,int).destination 'System\.Buffers\.Text\.Base64Url\.TryDecodeFromChars\(System\.ReadOnlySpan\<char\>, System\.Span\<byte\>, int\)\.destination'); otherwise `0`\.

#### Returns
[System\.Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean 'System\.Boolean')  
`true` on successful decode; `false` when the destination
            is too small\.

#### Exceptions

[System\.FormatException](https://learn.microsoft.com/en-us/dotnet/api/system.formatexception 'System\.FormatException')  
Thrown when [source](https://www.abblix.com/en/docs/api/abblix-utils/System.Buffers.Text.Base64Url#System.Buffers.Text.Base64Url.TryDecodeFromChars(System.ReadOnlySpan_char_,System.Span_byte_,int).source 'System\.Buffers\.Text\.Base64Url\.TryDecodeFromChars\(System\.ReadOnlySpan\<char\>, System\.Span\<byte\>, int\)\.source') contains
            a character outside the base64url alphabet, or when its length leaves a
            1\-character remainder modulo 4\.
