Blog
Wild & Free Tools

Base64 in HTTP Basic Authentication — How It Works

Last updated: February 27, 2026 5 min read

Table of Contents

  1. How Basic Auth Encodes Credentials
  2. Constructing Basic Auth Headers Manually
  3. Decoding a Basic Auth Header
  4. Basic Auth Security — The HTTPS Requirement
  5. Testing Basic Auth Headers
  6. Frequently Asked Questions

Every time you log in to a web service that uses HTTP Basic Authentication, your username and password are Base64-encoded and sent in the request header. This is a well-defined standard — not a random implementation choice — and it has important security implications that every developer should understand.

This guide explains exactly how Basic Auth uses Base64, how to construct and decode Authorization headers, and why this scheme is only safe over HTTPS.

How Basic Auth Encodes Credentials

The HTTP Authorization header for Basic authentication follows a precise format defined in RFC 7617:

  1. Combine username and password with a colon separator: username:password
  2. Base64-encode the combined string
  3. Prefix with Basic (with a space)
  4. Send in the Authorization header

Example — credentials admin:MyP@ssw0rd:

# Step 1: combine
admin:MyP@ssw0rd

# Step 2: Base64 encode
YWRtaW46TXlQQHNzdzByZA==

# Step 3+4: full header
Authorization: Basic YWRtaW46TXlQQHNzdzByZA==

You can verify this yourself: paste YWRtaW46TXlQQHNzdzByZA== into the Base64 decoder and you will see admin:MyP@ssw0rd — exactly as entered.

Constructing Basic Auth Headers in Code

When calling APIs that use Basic Auth, you often need to construct the header yourself:

# curl — built-in support
curl -u username:password https://api.example.com/endpoint

# curl — manual header
CREDENTIALS=$(echo -n "username:password" | base64)
curl -H "Authorization: Basic $CREDENTIALS" https://api.example.com/endpoint

# JavaScript (fetch)
const credentials = btoa('username:password');
fetch('https://api.example.com/endpoint', {
  headers: { 'Authorization': 'Basic ' + credentials }
});

# Python (requests library)
import requests
response = requests.get(url, auth=('username', 'password'))
# requests handles the Base64 encoding automatically

Note the -n flag in the bash example — this prevents echo from adding a newline character at the end of the string, which would corrupt the encoded output.

Sell Custom Apparel — We Handle Printing & Free Shipping

Decoding a Basic Auth Header to Inspect Credentials

To decode a Basic Auth header, strip the Basic prefix and decode the remaining Base64 string. The result is the username and password separated by a colon.

Using our free Base64 decoder: paste the Base64 portion (everything after "Basic ") and click Decode. You will immediately see the credentials in plaintext.

This is exactly why Basic Auth is not secure over plain HTTP. Any network device between the client and server — routers, proxies, Wi-Fi access points — can see the Authorization header, decode the Base64, and obtain the username and password in seconds. The Base64 encoding provides no confidentiality whatsoever; it is simply a formatting convention for the protocol.

Basic Auth Is Only Safe Over HTTPS

Basic Auth credentials are effectively sent in plaintext (Base64 is trivially reversible). The only thing that makes Basic Auth secure is the transport layer — HTTPS encrypts the entire HTTP request, including the Authorization header, between the client and server.

Rules for using Basic Auth safely:

Testing and Debugging Basic Auth Headers

When debugging API authentication issues, it helps to decode the Authorization header being sent to verify the credentials are correct. Common problems:

To quickly verify: take your credentials, encode them with our free tool, and compare the result character-by-character to what your application is sending. Paste the decoded version back to see if it matches what you intended to send.

Try It Free — No Signup Required

Runs 100% in your browser. No data is collected, stored, or sent anywhere.

Open Free Base64 Encoder/Decoder

Frequently Asked Questions

Is Base64 in HTTP Basic Auth a security measure?

No. Base64 encoding provides zero security — it is trivially reversible by anyone. Basic Auth is secure only because HTTPS encrypts the entire HTTP request including headers. Without HTTPS, Basic Auth credentials are effectively sent in plaintext.

Can I use any separator besides colon in Basic Auth credentials?

No. RFC 7617 specifies that the username and password are separated by a colon. If your password contains a colon, only the first colon is treated as the separator — everything after it is the password. Usernames cannot contain colons.

What is the difference between Basic Auth and Bearer token auth?

Basic Auth sends username and password (Base64-encoded) on every request. Bearer token auth sends an opaque token (typically a JWT) that was obtained from an authentication endpoint. Bearer tokens can be scoped, time-limited, and revoked individually without changing the underlying password.

Ryan Callahan
Ryan Callahan Lead Software Engineer

Ryan has been building browser-based utilities since the early days of modern browser technology. He architected the client-side processing engine that powers every tool on WildandFree — ensuring files never leave your browser.

More articles by Ryan →
Launch Your Own Clothing Brand — No Inventory, No Risk