Melotte Consulting
← Back to journal

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

Key takeaways

  • URL and Base64 encoding appear often enough in practice to be worth a dedicated shortcut.
  • Alfred workflows keep repetitive text transformations keyboard-accessible without a terminal.
  • Removing small friction points protects concentration during deeper or more complex work.

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.