How to Build a Basic Auth Header: Base64, UTF-8 and RFC 7617

Last updated: · 7 min read

HTTP Basic authentication is the oldest and plainest way to attach a username and password to a request: the two are joined with a colon, Base64-encoded and placed in the Authorization header. The scheme is defined in RFC 7617. Because it is so simple it is still used for internal services, test environments and many APIs, and for the same reason it is often misunderstood: Base64 is taken for encryption, a user whose password contains £ or ü cannot log in, and a colon in the username breaks the header. This guide shows how the header is built byte by byte, explains the two modes of the Basic Auth Header Generator & Decoder and sets out when the scheme is acceptable to use. The outputs in the examples are the tool's real results.

Formula

user-pass   = username + ":" + password
bytes       = UTF-8(user-pass)
credentials = Base64(bytes)
header      = "Authorization: Basic " + credentials

Generating — input: Username = Aladdin, Password = open sesame

Output:
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
curl -H "Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" https://example.com/

Note: Basic authentication is only Base64 encoding, not encryption; anyone who sees the header can read the password. Use it over HTTPS only.

Decoding — input (third field): Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==

Output:
Username: Aladdin
Password: open sesame
Character encoding: UTF-8
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==

Note: Basic authentication is only Base64 encoding, not encryption; anyone who sees the header can read the password. Use it over HTTPS only.

Under RFC 7617 the client concatenates the user-id, a single colon and the password, turns that text into bytes and Base64-encodes the bytes. Base64 (RFC 4648) maps every three bytes to four characters and pads the end with = when the byte count is not a multiple of three. Aladdin:open sesame is 19 bytes and gives a 28-character value ending in ==. RFC 7617 leaves the choice of character encoding to the client; a server can add charset="UTF-8" to its challenge to say that it expects UTF-8. This tool always encodes with UTF-8.

What the inputs mean

Username
Cannot be empty and cannot contain a colon (:), because the first colon separates the username from the password. Control characters such as line breaks and tabs are rejected.
Password
May be empty and may contain colons. Non-ASCII characters are converted to their UTF-8 bytes. Control characters are rejected.
Header to decode (optional)
If this field is filled in, the tool decodes instead of generating. You can enter a whole Authorization: Basic … line, a Basic … value or bare Base64; unpadded and URL-safe Base64 (with - and _) is accepted too.

Worked example: The example from RFC 7617: Aladdin and open sesame

  1. The username is Aladdin and the password is open sesame. They are joined with a colon: Aladdin:open sesame. The space in the password is part of the text.
  2. The text is turned into 19 bytes with UTF-8 and Base64-encoded: QWxhZGRpbjpvcGVuIHNlc2FtZQ==. Because 19 is not a multiple of three, the value ends in two = characters.
  3. The first output line is the header itself: Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==. The second line is a ready-made curl command carrying the same header.
  4. A non-ASCII character: for the username test and the password 123£ the tool produces Authorization: Basic dGVzdDoxMjPCow==. The £ sign is two bytes in UTF-8 (C2 A3), and the result matches the second example in RFC 7617.
  5. Encoded with ISO-8859-1, the same password would have £ as a single byte (A3) and the value would be dGVzdDoxMjOj. Give that value to the decoder and it still shows the password as 123£, but reports the encoding as: Character encoding: ISO-8859-1 (not valid UTF-8)
  6. A colon in the password is fine: for the username user and the password pa:ss the value is dXNlcjpwYTpzcw==, and because decoding splits at the first colon, it comes back as username user and password pa:ss.
  7. In decoding mode, entering Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== in the third field makes the tool show the username, the password, the character encoding and the header on four lines.

Result: For Aladdin and open sesame the header is Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==. The last line of the output is always the same reminder: Note: Basic authentication is only Base64 encoding, not encryption; anyone who sees the header can read the password. Use it over HTTPS only.

🔐 Basic Auth Header Generator & Decoder

Free, no sign-up; your data stays in your browser.

Open the calculator →

How to read the result

This header is a transport format, not a way of hiding anything. Base64 is a keyless, reversible encoding; anyone who sees the header can read the password by doing exactly what this tool's decoding mode does. RFC 7617 says plainly that the scheme is not considered a secure method of user authentication unless it is used together with a secure channel such as TLS, so use Basic authentication over HTTPS only. The password travels with every request, which raises the odds of it ending up in proxy logs, error reports and screenshots. Where you can, prefer a revocable, narrowly scoped access token over a user's password. Do not write credentials into the URL (https://user:password@host); RFC 9110 deprecates that form. The tool runs in your browser and sends the values you enter nowhere; the soundest habit is still not to type real passwords into any website and to experiment with a test account. This is general information.

Common mistakes

  • Mistaking Base64 for encryption. The encoding has no key and anyone can reverse it; confidentiality comes from HTTPS, not from Base64.
  • Putting a colon in the username. The tool rejects it: The username cannot contain a colon (:): per RFC 7617 the first colon separates the username from the password.
  • Sending the header over plain HTTP. Anyone on the network path can read the password.
  • Base64-encoding the username and the password separately and then joining them. The text user:password is built first and encoded as a whole.
  • Using different character encodings on the client and the server. A password containing £, é or ü gives different Base64 values in UTF-8 and ISO-8859-1; when logins work only with ASCII passwords, this is usually why.
  • Trying to decode a Bearer header with this tool. It decodes the Basic scheme only: Only the Basic scheme can be decoded; this header uses the Bearer scheme.
  • Pasting the header value into version control, a log file or a shared document. The header is the password; if it leaks, change the password.

Frequently asked questions

Is the Base64 in Basic Auth a form of encryption?

No. Base64 only maps bytes to printable characters; it involves no key and anyone can decode it. The tool repeats that at the end of every output. What protects the password on the network is the HTTPS connection.

Can the password contain a colon?

Yes. Under RFC 7617 the first colon separates the user-id from the password, and any later colons belong to the password. The username, however, cannot contain one.

Why does a password with accented or special characters fail?

Most likely the client and the server use different encodings. RFC 7617 does not fix a default; a server can announce that it wants UTF-8 with the charset="UTF-8" parameter. This tool produces UTF-8, and its decoding mode reads bytes that are not valid UTF-8 as ISO-8859-1 and says so in the output.

Is there a difference between curl -u and writing this header by hand?

curl -u user:password builds the same Authorization: Basic header for you. Writing the header by hand helps in tools without a -u option or when the value goes into a configuration file, which is why the output includes a ready-made curl -H line.

The server answers 401. How can I tell whether my header is right?

Paste the header you are sending into the decode field. If the username and password come out as expected, the header is well formed and the problem lies in the credentials or the character encoding. The server's WWW-Authenticate response header also shows which scheme it expects.

Are my username and password sent to a server?

No, encoding and decoding happen in your browser. The safest habit is still not to type real passwords into online tools.

The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.

Sources

Choose your cookie preference to continue

Records the site needs to work (theme, language, favourites) stay in your browser.

This site is free and funded by ads.

With your consent, Google Analytics cookies measure visits and Google AdSense cookies are used to show ads; the data is processed on Google servers abroad.

If you reject, the site works just the same.

Cookie Policy · KVKK notice