encoding/base64

Base64 encode or decode text, with optional URL-safe alphabet.

Free / no pricing configured

What it does

Encodes UTF-8 text to base64, or decodes base64 back to text. Supports the standard and URL-safe alphabets.

Primary use cases

  • Encoding a value for transport in a URL, header, or token.
  • Decoding a base64 string to read its contents.

Good to know

action is encode (default) or decode. Set url_safe to use the URL/filename-safe alphabet. Missing decode padding is tolerated. Decoding requires the result to be valid UTF-8 text. Computed locally.

Parameters

textstringrequired

Text to encode, or base64 string to decode.

actionstringoptional

Whether to encode or decode. Defaults to encode.

url_safebooleanoptional

Use the URL/filename-safe base64 alphabet. Defaults to false.

encoding/base64 — Faro