Base64 encoder and decoder
Encode text to Base64 or decode Base64 back to text, with standard and URL-safe alphabets.
Code examples
Copy and paste these into your own project. Each one uses only the language's standard library, so there is nothing to install.
const text = 'Hello, wereld! 👋'
const bytes = new TextEncoder().encode(text)
const encoded = btoa(String.fromCharCode(...bytes))
console.log(encoded)What it does
Base64 turns any bytes into plain text made of 64 safe characters, so binary data can travel through systems that only handle text: email bodies, JSON fields, URLs, data URIs and HTTP headers. This tool encodes text to Base64 and decodes Base64 back to text, entirely in your browser.
How to use it
- Choose Encode or Decode.
- Type or paste your text, or drop a file onto the input.
- Pick the standard alphabet (
+and/) or the URL-safe one (-and_), and whether to add=padding. - Copy the result, or send it straight to another tool.
Turn on the per-line option to convert every line on its own, for example a list of encoded values.
Examples
Encoding Hello, world! gives:
SGVsbG8sIHdvcmxkIQ==
The same bytes in the URL-safe alphabet without padding:
SGVsbG8sIHdvcmxkIQ
Good to know
- Base64 is an encoding, not encryption: anyone can decode it.
- The result is about a third larger than the input (every 3 bytes become 4 characters).
- Text is converted as UTF-8 by default. If decoded text shows strange characters, choose the charset it was written in.
- JSON Web Tokens use the URL-safe alphabet without padding.
What is Base64?
Base64 represents binary data using 64 printable characters, so it can travel through systems that only accept text, such as email bodies, JSON fields and data URLs. Every 3 bytes become 4 characters, which makes the result about 33% larger.
Frequently asked questions
When should I use the URL-safe alphabet?
Use it when the result goes into a URL or filename. It replaces + and / with - and _. JWTs use it without padding.
Why does my decoded text show strange characters?
The text was probably encoded with another charset than the one selected. Try ISO-8859-1, or check that the data is text and not a file.
Is Base64 encryption?
No. Anyone can decode Base64, so it hides nothing. Use it to transport data, never to protect it.