HTTP Basic Auth Encoder
Encode and decode HTTP Basic Authentication credentials. Generate the Authorization header value from username and password.
About this tool
HTTP Basic Auth Encoder builds and reads the value of the Authorization: Basic header, which is simply the base64 encoding of a username and password joined by a colon (username:password). It solves the everyday problem of having to manually assemble or decode that header when working with HTTP APIs.
To encode, enter a username and password and the tool returns the ready-to-use header value; to decode, paste an existing Basic header and it splits it back into the original credentials. This is handy for testing APIs, crafting curl or Postman requests, and debugging 401 Unauthorized responses where you need to verify what was actually sent.
Keep in mind that Basic auth base64 is only encoding, not encryption, so anyone who intercepts it can read the credentials. For that reason use it strictly over HTTPS. Everything here runs locally in your browser, and nothing you type is ever sent anywhere.
Frequently Asked Questions
Code Implementation
import base64
def encode_basic_auth(username: str, password: str) -> str:
credentials = f"{username}:{password}"
encoded = base64.b64encode(credentials.encode("utf-8")).decode("utf-8")
return f"Basic {encoded}"
def decode_basic_auth(header_value: str) -> tuple[str, str]:
b64 = header_value.removeprefix("Basic ").strip()
decoded = base64.b64decode(b64).decode("utf-8")
username, _, password = decoded.partition(":")
return username, password
header = encode_basic_auth("admin", "secret")
print(header) # Basic YWRtaW46c2VjcmV0
user, pwd = decode_basic_auth(header)
print(f"Username: {user}, Password: {pwd}")Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.