Basic Auth Decoder & Encoder
Decode HTTP Basic Authorization headers (Authorization: Basic …) into username:password, or build a header from credentials. Strips 'Basic ' prefix and whitespace automatically. Browser-only — credentials never leave your device.
Basic Auth Is Just Base64 of "user:password"
HTTP Basic Authentication (RFC 7617) is the simplest authentication scheme on the web. The client sends an Authorization header with the literal text Basic followed by Base64-encoded username:password. That's the entire protocol.
Authorization: Basic YWRtaW46c2VjcmV0
↓ base64 decode
admin:secret
↑ ↑
username password Anyone who intercepts that header — anyone on the network path, anyone with browser DevTools, anyone reading server logs — can decode it back to the original credentials in microseconds. Base64 is not encryption. The only thing protecting Basic Auth credentials in transit is HTTPS (TLS), which encrypts the whole request. Sending Basic Auth over plain HTTP is equivalent to sending the password in cleartext.
When Basic Auth Is Still Appropriate
Despite its simplicity, Basic Auth is widely used in 2026 in specific contexts:
- Server-to-server APIs where rotating credentials is acceptable and the connection is HTTPS-only — Stripe, Twilio, SendGrid, and many other SaaS APIs accept Basic Auth (often with the API key as username and empty password) as an alternative to Bearer tokens.
- Internal admin tools behind a VPN or company network, where adding a full OAuth flow would be overkill.
- Quick prototyping when you need authentication on day one and will replace it with proper OAuth or session auth before launch.
- Webhook signing — some platforms (Mailgun, Twilio's older webhooks) include Basic Auth as part of webhook delivery so the receiver can verify the request.
For user-facing applications and anything with multiple users / scopes / sessions, use OAuth 2.0 + JWT Bearer tokens instead. Bearer tokens support expiry, scopes, revocation, and don't require sending the password on every request.
Edge Cases the Decoder Handles
This decoder accepts a wide variety of input shapes:
Authorization: Basic YWRtaW46c2VjcmV0(full header line)Basic YWRtaW46c2VjcmV0(header value only)YWRtaW46c2VjcmV0(raw Base64)"Basic YWRtaW46c2VjcmV0"(quoted, e.g. from JSON)- Surrounding whitespace, newlines, leading/trailing commas
The parser strips the prefix and any wrapping characters before Base64-decoding. The result is split on the FIRST colon — passwords containing colons survive intact (e.g., user:pass:word → username user, password pass:word).
Encoding in Code
// Node.js
const auth = 'Basic ' + Buffer.from(`${user}:${pass}`).toString('base64');
// Python
import base64
auth = "Basic " + base64.b64encode(f"{user}:{pass}".encode()).decode()
// Browser
const auth = 'Basic ' + btoa(`${user}:${pass}`);
// Bash / curl
curl -u user:password https://api.example.com/ // curl handles encoding
curl -H "Authorization: Basic $(echo -n 'user:pass' | base64)" https://api.example.com/ Security Best Practices
- Always use HTTPS. Basic Auth over HTTP is equivalent to plaintext passwords. Some browsers now show "Not secure" warnings for HTTP+Basic combinations.
- Store the encoded header, not the password. Application config should hold the full
Basic …string, not the cleartext credentials. Less serialization mistakes. - Never log Authorization headers. Most logging frameworks have a default redaction list — make sure
Authorizationis on it. Audit logs that show full headers are a credential disclosure waiting to happen. - Use unique credentials per service. One leaked Basic Auth credential should not unlock multiple integrations.
- Rotate periodically — at minimum yearly, immediately after any incident.
- For Stripe-style APIs that take an API key as username, the password field is intentionally empty — the encoded form is
Basic c2tfdGVzdF9hYmM6(note the trailing colon).
For other token formats, see the JWT Decoder. To generate fresh credentials, use the Random Token Generator.
How to Use
- Decode mode — paste the
Authorizationheader (or just the Base64). The parser handles 'Basic' prefix, quotes, and whitespace. - Encode mode — type a username and password to get the full
Basic …header. - Copy the result — round-trip safe: encode then decode returns the original.
- Never use this on HTTP — only over HTTPS.
Frequently Asked Questions
What is HTTP Basic Authentication?
Basic Auth (RFC 7617) is a simple HTTP authentication scheme where the client sends an Authorization header containing the literal string 'Basic ' followed by Base64-encoded 'username:password'. The server decodes the header and verifies the credentials. It's the simplest form of HTTP auth and is still widely used for internal APIs, server-to-server calls, and quick prototyping.
Is Base64 encryption?
No. Base64 is encoding, not encryption — anyone who sees the encoded string can decode it instantly with a tool like this one. Basic Auth provides zero confidentiality on its own. The only thing that protects your password in transit is HTTPS (TLS), which encrypts the entire HTTP request including the Authorization header. Never use Basic Auth over plain HTTP.
What does the encoded form look like?
Base64-encoded UTF-8 of 'username:password'. For example, 'admin:secret' becomes 'YWRtaW46c2VjcmV0', and the full header is 'Authorization: Basic YWRtaW46c2VjcmV0'. The colon is the separator — passwords cannot contain colons. The username and password are encoded together, then the result is treated as one opaque token by the auth layer.
Why does the decoder strip 'Basic ' and whitespace?
Real-world headers come pasted from cURL output, browser DevTools, or log files with various surrounding context. The parser tolerates: leading 'Authorization:' or 'authorization:', the literal word 'Basic' or 'basic' followed by whitespace, surrounding quotes ("…"), and trailing newlines or commas. You can paste 'Authorization: Basic YWRtaW46c2VjcmV0' or just 'YWRtaW46c2VjcmV0' — both work.
Can passwords contain colons?
No — at least, not in the way you think. The colon between username and password is the separator. If a password contains a colon, decoding splits it on the FIRST colon: 'user:pass:word' decodes to username='user' and password='pass:word'. This is per RFC 7617. If your password has special characters, percent-encode them (the spec recommends UTF-8 with %-encoding for non-ASCII, though many implementations just use raw UTF-8).
When should I use Basic Auth vs. Bearer tokens?
Use Basic Auth for: machine-to-machine APIs where rotating credentials is acceptable, internal admin tools behind a VPN, dev/staging environments. Use Bearer tokens (Authorization: Bearer …) for: user-facing apps, OAuth flows, anywhere you need short-lived or scoped credentials. Modern public APIs almost universally use Bearer tokens because they support expiry, scopes, and revocation without resetting passwords.
Comments
No comments yet. Be the first!