26 Unix tools. One binary. Zero dependencies.·the missing coreutils for the agent era·vrk mcp - expose all 26 tools to any AI agent·curl vrk.sh/install.sh | sh - ready in 5 seconds·

vrk base

vrk base encodes and decodes base64, base64url, hex, and base32 with identical behavior on every platform.

The problem

base64 behaves differently on macOS and Linux. macOS wraps output at 76 characters. -w0 disables wrapping on Linux but does not exist on macOS. -d means decode on macOS, --decode on Linux. A script that works locally breaks in CI on a different OS.

The solution

vrk base encodes and decodes base64, base64url, hex, and base32 with identical behavior on every platform. Two subcommands: encode and decode. Strips one trailing newline from stdin so echo input works correctly. No platform-specific flags to remember.

Before and after

Before

# macOS
echo 'hello' | base64
# Linux
echo 'hello' | base64 -w0
# Different flags, different output

After

echo 'hello' | vrk base encode --to base64

Example

echo 'hello' | vrk base encode --to base64

Exit codes

CodeMeaning
0Success
1Invalid encoded input (bad characters, wrong padding)
2Missing subcommand, –to/–from missing or unsupported

Flags

FlagShortTypeDescription
--tostringTarget encoding: base64, base64url, hex, base32 (encode subcommand)
--fromstringSource encoding: base64, base64url, hex, base32 (decode subcommand)
--quiet-qboolSuppress stderr output

Supported encodings

EncodingFlag valueExample output
Base64base64aGVsbG8=
Base64urlbase64urlaGVsbG8 (no padding, URL-safe)
Hexhex68656c6c6f
Base32base32NBSWY3DP

How it works

Encode

$ echo 'hello' | vrk base encode --to base64
aGVsbG8=

$ echo 'hello' | vrk base encode --to hex
68656c6c6f

$ echo 'hello' | vrk base encode --to base64url
aGVsbG8

Decode

$ echo 'aGVsbG8=' | vrk base decode --from base64
hello

$ echo '68656c6c6f' | vrk base decode --from hex
hello

Trailing newline handling

echo appends a newline. vrk base strips exactly one trailing newline before encoding, so echo 'hello' and printf 'hello' produce the same result. Use printf 'hello\n' if you want the newline included.

Pipeline integration

Decode a base64 field from JSON

echo "$JWT_PAYLOAD" | vrk base decode --from base64url | jq .

Encode content for embedding in JSON

ENCODED=$(cat binary-file | vrk base encode --to base64)
echo "{\"data\":\"$ENCODED\"}" | vrk kv set --ns cache payload

When it fails

Invalid base64 input:

$ echo '!!invalid!!' | vrk base decode --from base64
error: base: illegal base64 data at input byte 0
$ echo $?
1

Missing encoding flag:

$ echo 'hello' | vrk base encode
usage error: base encode: --to is required
$ echo $?
2