Codec lesson · Base64URL

Base64URL: Base64 for filenames and URLs

Base64URL is the RFC 4648 URL- and filename-safe alphabet. It replaces + and / with - and _, while Encode Keyboard emits the optional padding-free form.

Standard · RFC 4648 Round trip: Exact for canonical Base64URL whose decoded bytes are valid UTF-8 text, including an initial U+FEFF when present.
Learning objective

Distinguish Base64URL from standard Base64 and validate a canonical UTF-8 text value without confusing encoding with encryption.

Encode Keyboard converts UTF-8 bytes with the RFC 4648 Base64URL alphabet and removes trailing = padding. Decode accepts canonical unpadded text or exactly the required padding, then requires valid UTF-8.

01

How Encode Keyboard handles it

1

Start with UTF-8 bytes

Text first becomes the same byte sequence used by the other exact data formats.

2

Use the URL-safe alphabet

The indices that standard Base64 writes as + and / are written as - and _.

3

Validate before returning text

Decode checks the alphabet, impossible lengths, allowed padding, canonical re-encoding, and UTF-8 output.

02

Worked example

InputHello?
OutputSGVsbG8_

The final _ is the URL-safe symbol where standard Base64 would use /. Encode Keyboard omits = padding.

03

Good uses

  • Reading URL-safe tokens that are documented as Base64URL
  • Learning the difference between Base64 alphabets
  • Moving non-sensitive UTF-8 text through filename-safe fields
04

Validation and common errors

  • Use only A–Z, a–z, 0–9, - and _ before optional trailing =
  • Do not mix + or / from standard Base64
  • Padding, when present, must be exactly the amount required by the final block
05

Practice in your browser

This uses the same documented rules as the app and runs only in this tab.

Base64URLThis uses the same documented rules as the app and runs only in this tab.
Result

This uses the same documented rules as the app and runs only in this tab.

06

Knowledge check

Which characters replace + and / in the Base64URL alphabet?