| Task | Mac / Linux | Windows (PowerShell) |
|---|---|---|
| Encode text | echo -n "text" | base64 | [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("text")) |
| Decode text | echo "dGV4dA==" | base64 -d | [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String("dGV4dA==")) |
| Encode file | base64 file.png | [Convert]::ToBase64String([IO.File]::ReadAllBytes("file.png")) |
| Decode to file | base64 -d encoded.txt > file.png | [IO.File]::WriteAllBytes("file.png",[Convert]::FromBase64String($b64)) |
Note: Mac uses base64 -D (capital D) for decode, while Linux uses base64 -d (lowercase). This trips up everyone switching between systems.
Don't want to remember terminal syntax? The browser-based Base64 tool works on every platform — paste text or drop a file, get the result instantly.
Authorization: Basic dXNlcjpwYXNz header is Base64. Decode it to see the credentials: user:pass. Use the Base64 tool or the JWT Decoder for full JWT tokens.data:image/png;base64,... save HTTP requests. Encode the image file to get the Base64 string.echo "text" | base64 encodes a trailing newline. Use echo -n "text" | base64 to avoid it. This causes subtle bugs when encoding API credentials.+ and / which break URLs. Base64URL uses - and _ instead. JWTs use Base64URL. The browser tool auto-detects which variant you paste.=) — Base64 output is padded with = to make the length a multiple of 4. Some systems strip padding. The tool handles both padded and unpadded input.Use the terminal when you are already in the command line (scripting, piping output, CI/CD). The one-liners above are fastest when you are already in a shell session.
Use the browser tool when:
Try Base64 Encoder — free, private, unlimited.
Open Base64 Encoder