28 Unix tools. One binary. Zero dependencies.·the missing coreutils for the agent era·try vrk in your browser at vrk.sh/play·curl vrk.sh/install.sh | sh - ready in 5 seconds·

vrk base

Try it in your browser

vrk, compiled to WebAssembly

# Encodes text as base64. Use decode to go back.

Enter runs, Shift+Enter adds a line
    output
    Press RUN. Nothing leaves your browser.

    files you can cat:

    Edit the command and press RUN. Open the full playground for more recipes, or install vrk to run it on your own files.

    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. It has two subcommands: encode and decode. It strips one trailing newline from stdin, so echo input works as you expect. It has no platform-specific flags.

    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

    vrk base encodes and decodes text as base64, base64url, hex, or base32.

    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 adds a newline. vrk base removes exactly one trailing newline before it encodes, so echo 'hello' and printf 'hello' give the same result. To keep the newline, use printf 'hello\n'.

    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: invalid base64 input
    $ echo $?
    1
    

    Missing encoding flag:

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