Basic Auth Encoder – Free

Enter a username and password, and this Basic Auth encoder returns the value for the Authorization header: the word Basic followed by the Base64 of username:password.

How to use the Basic Auth encoder tool

  1. Type the user name into the Username box. It cannot be empty or contain a colon.
  2. Type the password into the Password box. Select Example to fill in alice and sample.
  3. Select Encode to build the header value.
  4. Select Copy to take the value, which starts with Basic, and send it as the Authorization header of your request.

How Basic authentication builds the header

RFC 7617 defines the scheme. The client joins the user name and the password with a single colon, converts that string to bytes, encodes the bytes as Base64 and puts the word Basic and a space in front. The server reverses the steps and splits the decoded string at the first colon.

That split rule explains the one restriction on input: a colon in the user name would shift the boundary, so it is forbidden, while colons in the password are harmless. This tool encodes the joined string as UTF-8 and writes standard Base64 with padding.

A worked example

The joined string alice:sample is 12 bytes, which is four complete groups, so the token is 16 characters with no padding. The curl line shows where the value goes. With curl you can also pass -u alice:sample and let it do the encoding.

Username:  alice
Password:  sample
Joined:    alice:sample
Result:    Basic YWxpY2U6c2FtcGxl

curl -H "Authorization: Basic YWxpY2U6c2FtcGxl" https://example.com/api

Input rules of the Basic Auth encoder

The form is small, but a few details decide whether the server accepts the header.

  • Username is required. An empty value or one with a colon stops with Enter a username without colons.
  • Password may be empty. The colon is still added, so alice alone gives Basic YWxpY2U6.
  • Nothing is trimmed. A space before or after either value becomes part of the credentials.
  • Characters outside ASCII are encoded as UTF-8. A server that assumes ISO-8859-1 will see a different password.
  • The result is the header value only. Add the header name Authorization yourself.
  • The Password box is a normal text field, so the password is visible on screen as you type.

Security: Base64 is not encryption

The token is the user name and password in a different spelling. Anyone who sees the header can decode it, and the client sends it again with every request. Use Basic authentication only over HTTPS, keep the header out of URLs, logs and screenshots, and do not commit it to a repository.

Many APIs use the scheme for keys: the key goes in as the user name and the password stays empty. The same encoding is used for the Proxy-Authorization header. To inspect an existing header, use the Basic Auth Decode tool on this site.

Frequently asked questions

How do I create a Basic Authorization header?

Join the user name and password with a colon, Base64 encode the result and write Basic plus a space before it. The complete header line is Authorization: Basic followed by the token. This tool produces everything after the header name.

Can the password contain a colon?

Yes. Servers split the decoded credentials at the first colon only, so everything after it belongs to the password. The user name is the part that must not contain one.

Is Basic authentication secure?

Only as secure as the connection. The credentials are encoded, not encrypted, so on plain HTTP they can be read by anyone on the path. Over HTTPS the header is protected in transit like the other request data.

How do I send an API key with Basic auth?

Follow the API's documentation. A common convention is the key as Username and an empty Password. The encoded string then ends with the colon, which is required even though no password follows it.

Why does the server reject my generated header?

Typical causes are a stray space typed into either box, non-ASCII characters on a server that does not expect UTF-8, or sending the token without the word Basic. Some servers expect a different scheme, such as Bearer.

Are my credentials sent to Base64Coding?

No. The header is built by JavaScript in the page and the form submits nothing to a server. Still, avoid typing production passwords on shared or untrusted computers.

Related tools