Basic auth generator

Generate a base64 basic auth header from a username and password.

loading Basic auth generator
About this tool

What is a Basic auth header?

HTTP Basic authentication is the simplest way for a client to identify itself to a server. The client sends an Authorization header with the word Basic followed by the text username:password encoded in Base64. The scheme is defined in RFC 7617 and is still everywhere: internal APIs, staging sites behind a password prompt, package registries, Prometheus and Elasticsearch endpoints, webhooks and reverse proxies configured with htpasswd.

The important thing to understand is that Base64 is an encoding, not encryption. Anyone who sees the header can decode it in a second, which is why Basic auth must only travel over HTTPS. This page builds the header for you, and it also works the other way round: paste a header you captured and it shows the username and password inside. That is handy when you debug a 401 and need to know which credentials a client is really sending. The Base64 step itself is the same one the Base64 tool performs.

The generator builds the token from username:password as UTF-8, then gives you three things ready to copy: the full Authorization: Basic ... header, the bare token, and a curl command. It runs entirely in your browser, so the credentials you type, even real ones from a test environment, are not sent anywhere. Because the first colon separates the two parts, a username cannot contain one, while a password may. If you need a strong password for the account, the token generator makes one, and the password strength analyser checks it.

How to generate a Basic auth header

  1. Type the Username. The page opens with aladdin and open sesame as an example, the pair used in the RFC.
  2. Type the Password. The header updates as you type.
  3. Read the line Authorization header and press Copy header to take the whole line, Copy token for just the Base64 part, or Copy curl for a ready command against https://example.com that you adapt to your URL.
  4. To go the other way, use the card Decode a header: paste a full header (Authorization: Basic ...) or only the Base64 token, and read the decoded Username and Password.
  5. Put the header in your HTTP client, in the Authorization field of Postman or Insomnia, or in a proxy configuration.

Examples

The example from the RFC

Username Aladdin, password open sesame:

Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==

The page opens with the lowercase aladdin, which gives YWxhZGRpbjpvcGVuIHNlc2FtZQ==. A single capital letter changes the whole token, because Base64 encodes every byte.

A realistic credential

Username maria.silva, password s3nha-forte:

Authorization: Basic bWFyaWEuc2lsdmE6czNuaGEtZm9ydGU=

Decode it and you get maria.silva:s3nha-forte back, with nothing hidden.

Accents and other non-ASCII characters

Username api, password pässwörd: the text is encoded as UTF-8 before Base64, so the token is:

YXBpOnDDpHNzd8O2cmQ=

Whether the server reads the credentials as UTF-8 is up to the server; RFC 7617 lets it declare so with charset="UTF-8". If login fails only with accented passwords, that is the first suspect.

A colon inside the password

Username user, password pa:ss is fine and gives dXNlcjpwYTpzcw==. The decoder splits at the first colon only, so the password comes back whole. The same colon in the username is rejected.

The curl command

The generator produces a command like this, with the header single-quoted so the shell leaves it alone:

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

Common errors and how to fix them

  • "A username cannot contain ":" (the first colon separates the username from the password).": remove the colon from the username, or move it to the password.
  • "Paste an Authorization header or the base64 token.": the decode box is empty.
  • "This is not Basic auth, it is Bearer.": the pasted header uses another scheme, such as Bearer or Digest. A Bearer token is not Base64 of user:password; for JWTs use the JWT tool.
  • "This is not valid base64. Paste the part after "Basic".": the text was cut, has extra characters or includes the word Basic twice.
  • "The decoded text has no ":" between username and password.": the token decodes, but it is not a user:password pair, probably an API key.
  • The server still answers 401: check for a trailing space or newline in the password, the wrong environment, or a missing Basic prefix in the header.

Frequently asked questions

Is Basic authentication secure?

Only over HTTPS, and even then it sends the password with every request, so it suits internal tools and simple integrations more than public applications. For anything user-facing prefer tokens or OAuth. Never use Basic over plain HTTP.

Is the Basic auth token encrypted?

No. It is Base64, which anyone can reverse, as the decoder on this page shows. Treat the header as being as sensitive as the password itself.

How do I send Basic auth with curl?

Either paste the header with -H, as the generator does, or let curl build it with -u username:password. Both produce the same request.

Why does my username with an @ or accents fail?

An @ is fine. Accents depend on the encoding the server expects; the page uses UTF-8. A colon is the only character that is never allowed in the username.

What is the difference between Basic and Bearer?

Basic carries a username and password on each call. Bearer carries an opaque token or a JWT that was issued earlier. Both go in the Authorization header with a different word.

Send Basic auth in code

JavaScript

const token = Buffer.from('maria.silva:s3nha-forte').toString('base64');
const res = await fetch('https://example.com/api', {
  headers: { Authorization: `Basic ${token}` },
});

Python

import requests

res = requests.get('https://example.com/api', auth=('maria.silva', 's3nha-forte'))

Go

req, _ := http.NewRequest("GET", "https://example.com/api", nil)
req.SetBasicAuth("maria.silva", "s3nha-forte")

Bash

curl -u 'maria.silva:s3nha-forte' https://example.com/api
Report a problem