Melotte Consulting

Journal entry

Automating string encoding with Alfred

A lightweight Alfred workflow for URL and Base64 encoding that keeps common text transformations quick and close to the work.

article Productivity 13 Sept 2025 4 min read

Why this entry exists

  • Useful notes belong on the main site when they help people make better use of systems in practice.
  • The goal is clearer workflows, better operational decisions, and fewer avoidable workarounds.
  • If a guide is worth writing, it should be easy to find and easy to return to later.

Small workflow shortcuts matter because they remove the tiny interruptions that break concentration.

String encoding is a good example. It is not a big task, but it appears often enough that it benefits from a fast path.

This workflow handles two common jobs:

  • URL encoding
  • Base64 encoding

Useful input methods

One of the reasons the workflow is helpful is that the source text can come from a few places:

  1. clipboard contents for quick ad hoc encoding
  2. a direct argument when you already know the exact input
  3. selected text through Alfred Universal Actions

That flexibility means the shortcut works inside the flow you are already in, rather than forcing a copy-paste ritual every time.

URL encoding

#!/bin/zsh
TEXT="$1"

if [ -z "$TEXT" ]; then
  TEXT=$(pbpaste)
fi

/usr/bin/osascript -l JavaScript -e "encodeURIComponent('$TEXT')"

Base64 encoding

#!/bin/zsh
TEXT="$1"

if [ -z "$TEXT" ]; then
  TEXT=$(pbpaste)
fi

echo -n "$TEXT" | base64

Why this kind of shortcut matters

The point is not that encoding is hard. The point is that small workflow annoyances add up when they appear repeatedly through the week.

This sort of automation sits in the same general category as other useful utility shortcuts, like UUID and key generation with Alfred: tiny pieces of friction removed close to the point where they actually occur.

Need help applying something like this in a live workflow?

Reading a guide is often enough to clarify the pattern. If the workflow is already messy, brittle, or hard to trust, the better next step is usually to look at the operational problem directly.