Base64 Encode

Type or paste text to get its Base64 encoding as you type, or encode a whole file to a data URI. Emoji and accented characters are encoded as UTF-8.

Text input

Base64 output

How to Base64-encode

  1. Type or paste your text. The encoding updates as you type.
  2. Tick URL-safe for tokens and URLs (uses - and _, drops = padding).
  3. For images, PDFs or any binary, use Encode a file… to get a data: URI.

Common uses

  • HTTP Basic authentication: Authorization: Basic + Base64 of user:password.
  • Embedding small images or fonts in CSS and HTML (see image to Base64).
  • Putting binary data in JSON, YAML (Kubernetes Secrets store values Base64-encoded) or environment variables.

Base64 is not encryption: anyone can decode it. Output is about 33% larger than the input.

Questions

How do I Base64-encode a string in JavaScript?

For ASCII, btoa(str). For any Unicode text, encode to UTF-8 first: btoa(String.fromCharCode(...new TextEncoder().encode(str))), or in Node.js Buffer.from(str).toString("base64").

How do I encode for a Kubernetes Secret?

Paste the raw value and copy the output. Make sure you didn’t include a trailing newline — echo -n on the command line does the same thing.

Related tools