---
title: "Base64 Encode action for ActionClip"
canonical_url: "https://actionclip.app/actions/base64-encode"
document_type: "standalone_action"
official: true
action_count: 1
catalog_schema_version: 1
catalog_revision: "2026-08-21.1"
catalog_published_at: "2026-08-20T18:50:00Z"
---

# Base64 Encode action for ActionClip

Encode selected Unicode text as Base64 UTF-8.

## What it does

Converts Unicode to UTF-8 bytes and emits standard padded Base64 without relying on browser or Node.js APIs.

## Action details

| Field | Value |
| --- | --- |
| Category | Developer Tools |
| Action type | JavaScript |
| Result | Replace or copy text |
| Internet | Not required |

## Action and outcome

| Action | Outcome |
| --- | --- |
| **Base64 Encode** — Selected text: ActionClip | QWN0aW9uQ2xpcA== |

## How to encode selected Unicode text as Base64 UTF-8 with ActionClip

1. Select the text you want to use.
2. Choose **Base64 Encode** from ActionClip.
3. Review the result, then replace the selection or copy the new text.

## Requirements

No setup required.

## Privacy

Runs locally in ActionClip’s JavaScript sandbox. Selected text does not leave your Mac.

## Action configuration

````javascript
function run(selected_text) {
  const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  const bytes = [];

  for (let index = 0; index < selected_text.length; index += 1) {
    let codePoint = selected_text.charCodeAt(index);
    if (codePoint >= 0xD800 && codePoint <= 0xDBFF) {
      const low = selected_text.charCodeAt(index + 1);
      if (low >= 0xDC00 && low <= 0xDFFF) {
        codePoint = 0x10000 + ((codePoint - 0xD800) << 10) + (low - 0xDC00);
        index += 1;
      } else {
        codePoint = 0xFFFD;
      }
    } else if (codePoint >= 0xDC00 && codePoint <= 0xDFFF) {
      codePoint = 0xFFFD;
    }

    if (codePoint <= 0x7F) {
      bytes.push(codePoint);
    } else if (codePoint <= 0x7FF) {
      bytes.push(0xC0 | (codePoint >> 6), 0x80 | (codePoint & 0x3F));
    } else if (codePoint <= 0xFFFF) {
      bytes.push(0xE0 | (codePoint >> 12), 0x80 | ((codePoint >> 6) & 0x3F), 0x80 | (codePoint & 0x3F));
    } else {
      bytes.push(0xF0 | (codePoint >> 18), 0x80 | ((codePoint >> 12) & 0x3F),
        0x80 | ((codePoint >> 6) & 0x3F), 0x80 | (codePoint & 0x3F));
    }
  }

  let output = "";
  for (let index = 0; index < bytes.length; index += 3) {
    const first = bytes[index];
    const second = index + 1 < bytes.length ? bytes[index + 1] : 0;
    const third = index + 2 < bytes.length ? bytes[index + 2] : 0;
    const value = (first << 16) | (second << 8) | third;
    output += alphabet[(value >> 18) & 63];
    output += alphabet[(value >> 12) & 63];
    output += index + 1 < bytes.length ? alphabet[(value >> 6) & 63] : "=";
    output += index + 2 < bytes.length ? alphabet[value & 63] : "=";
  }
  return output;
}
````

## Links

- [HTML listing](https://actionclip.app/actions/base64-encode)
- [Download action definition](https://actionclip.app/actions/base64-encode.actionclip)
- [Browse Developer Tools actions](https://actionclip.app/marketplace#marketplace-developerTools)
- [All Marketplace listings](https://actionclip.app/marketplace)
