If you are a backend developer, a DevOps engineer, or just someone trying to set up Basic Authentication, you've dealt with Base64. You've probably also spent 15 minutes confused by why your generated hash has a weird line break in it, breaking your API request.

Let's be honest: the command-line tools for Base64 encoding are inconsistent across operating systems. Here is the cheat sheet you actually need, and a faster way to do it.

The OS Inconsistency Nightmare

If you need to base64 encode a file in Linux, you might use the base64 command. But by default, it wraps lines every 76 characters. If you are trying to pass that string into a JSON payload or an HTTP header, it will fail.

# Linux (GNU Coreutils) - You must add -w 0 to remove line breaks
echo -n "username:password" | base64 -w 0

But what if you are on a Mac? Mac uses the BSD version of Base64, so the flag is completely different:

# Mac (BSD) - You must add -b 0
echo -n "username:password" | base64 -b 0

If you are on Windows PowerShell, it's a totally different command that feels like an alien language:

# Windows PowerShell
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("username:password"))

How to Base64 Encode Username and Password

This is the most common use case, especially when testing APIs in Postman or cURL. You take the string username:password, encode it to Base64, and pass it in the Authorization header: Basic [base64_string].

If you make a typo or leave a trailing space, your API returns a 401 Unauthorized, and you waste half an hour debugging.

The Zero-Friction Solution

Why memorize these inconsistent flags when you can just paste your data and get the result instantly?

Use our free Base64 Encoder/Decoder.

It's built specifically to solve the line break issue. It runs entirely in your browser using JavaScript, so your passwords and API secrets are never sent to a server. Paste your string, hit encode, and get the exact clean string you need for your headers.

Next time you need to test Basic Auth or encode a file, skip the terminal headaches and use the online tool. Your workflow will thank you.