YWRtaW46c2VjcmV0Authorization: Basic YWRtaW46c2VjcmV0curl -H "Authorization: Basic YWRtaW46c2VjcmV0" https://example.com/apiAbout Basic Auth Generator
HTTP Basic authentication joins a username and password with a colon, Base64-encodes the result, and sends it in an Authorization: Basic <credentials> header. This tool generates that Base64 credential, the full header and a copy-ready curl example from the username and password you enter, handy for debugging protected endpoints or configuring curl and Postman. For example, admin with password secret produces Authorization: Basic YWRtaW46c2VjcmV0 for API testing. Basic authentication is the simplest scheme HTTP itself provides: join the username and password with a colon, encode once, and send the result in a request header. It still has clear uses today, putting a minimal gate on an internal API, a test environment or a monitoring endpoint, or making do in an integration where the other side supports nothing else, but it is unsuited to carrying a real user system. The essential point about the mechanism is that it encodes rather than encrypts, so it must run over transport encryption or anyone on the network path can recover the plaintext credentials. The encoding is the standard binary-to-text scheme, not a hash and with no salt. So the same username and password always produce an identical header, which has two consequences: replay cannot be prevented, and browsers and intermediaries treat it as an ordinary header to be cached or printed into logs. Practical notes: If you must verify it server-side, do so over transport encryption and compare in constant time to avoid leaking password length or prefix through response timing, and always add rate limiting, since such endpoints are prime targets for brute force. During front-end debugging, note that browsers cache the credentials and make logging out hard, with many implementations requiring a cleared session or a different browser, so keep a clean profile available for testing. Limits: No individual logout, no expiry and no notion of scope: those three together restrict it to the crudest access control. It also surfaces in proxy logs, error reporting and developer tools, so it must never front a public service. When temporary access must be shared by link, use a time-limited one-time token instead of encoding long-lived credentials into a URL. Data and privacy: this tool generates and checks credential strings, so the input is a real username and password, which makes it highly sensitive. Conversion happens entirely in the browser without uploading, but the safer routine is to enter a lookalike example with the same structure for a format check rather than using production credentials in an online tool. The main misuse is treating it as a usable user system: this scheme has no individual logout, no expiry and no notion of scope. The credential surfaces in proxy logs, error reports and developer tools, so it must never front a public service. Another is using it without transport encryption, where anyone on the network path recovers the plaintext password.
How It Works Internally
The credential is the username and password joined by a colon in raw form and encoded once, with no escaping and no hashing, so this is encoding rather than encryption: it must run over transport encryption or anyone on the path can recover the plaintext. The same username and password always produce an identical header, so replay cannot be prevented and there is no individual logout or expiry.
Username aladdin, password open sesameAuthorization: Basic YWxhZGRpbjpvcGVuIHNlc2FtZQ== (any decoder recovers the plaintext)Measured on This Page
| Standard vectors | 5/5 match (admin:secret / user:pass / Aladdin:open sesame / empty user / empty pass) |
|---|---|
| Non-ASCII encoding | 用户:🔑 → 55So5oi3OvCflJE=, matching the UTF-8 requirement of RFC 7617 |
| Decode loop | The page output decodes back exactly to 用户:🔑 |
| Google, last 90 days | 5 clicks / 63 impressions / average position 27.0 |
RFC 7617 says credentials are UTF-8 encoded before base64. Until 2026-10-27 this page called btoa directly — which only accepts Latin1, so Chinese or emoji input threw InvalidCharacterError and the result froze on the old value (verified in-browser); it now goes through TextEncoder. The common tutorial wrapper btoa(unescape(encodeURIComponent(s))) is equivalent to the RFC; when Base64 outputs disagree, first check both sides agree on UTF-8.
How to Use
- Open "Basic Auth Generator"
- Fill the username and password fields
- The Base64 token and Authorization header appear live
- Click the copy icon beside each result to paste into curl
Use Cases
- Debug protected APIs — Quickly build an Authorization header for curl or Postman to reach authed endpoints.
- Configure reverse proxy — Set Basic credentials in Nginx or a gateway and verify the encoding is correct.
- Verify encoded output — Compare the generated header with the credential seen in a proxy to confirm both sides encode alike.
- Protect internal services — Generate simple Basic Auth credentials for CI or monitoring dashboards.
- Write doc examples — Provide copy-ready requests with an auth header in API documentation.
- API gateway testing — Generate credentials for testing authentication flows through API gateways like Kong, AWS API Gateway, or Traefik.
- CI/CD pipeline auth — Build Basic Auth headers for programmatic access to private package registries or CI artifact repositories.
FAQ
Is Basic Auth secure?
Base64 is reversible encoding, not encryption, so credentials are essentially plaintext. Always use it over HTTPS; otherwise any node on the path can trivially recover the username and password.
What if the username or password has a colon?
The spec forbids colons in the username (it is the delimiter) but allows them in the password. Decoding splits on the first colon, so colons in the password are preserved.
Why do non-ASCII passwords break?
Historically Basic Auth had no agreed encoding for non-ASCII; RFC 7617 recommends UTF-8. If the server uses a different charset, passwords with accents or Chinese may fail.
Basic vs Bearer?
Basic sends the username and password on every request; Bearer carries an access token (like a JWT) with configurable expiry and scope, better suited to modern APIs. Use our JWT tools to create one.
Are credentials cached?
Within a session a browser may cache Basic credentials and auto-attach them to same-origin requests, so logging out often means closing the tab or clearing the session, an inherent limitation of Basic Auth.
The browser keeps prompting for credentials even though they are correct. Why?
The usual cause is a 401 response without a realm hint, so the browser cannot tell which path the credentials apply to and asks again for every request under it. Another possibility is that a wrong value got cached: closing the tab is not enough, you need to quit the whole browser process or clear the stored credentials for the site. Check that the response consistently returns 401, and confirm the credential string has no stray whitespace.
Can the username or password contain a colon or non-ASCII characters?
The credential is the username and password joined by a colon in their raw form and encoded as a whole, with no escaping. A colon inside the username makes the server split at the first one, so the two parts shift; non-ASCII characters depend on the character set each side assumes, which easily yields a case that passes locally while the server decodes mojibake. The safe range is printable ASCII for both.
Can I use the generated Authorization header directly?
Yes — it is the standard Basic base64(user:password). But Basic sends credentials in clear text and requires HTTPS, and many modern APIs have moved to Bearer tokens. Confirm which scheme the server expects before debugging 401s.