How to Encode and Decode Base64
Base64 is one of those things developers deal with constantly — embedding images in CSS, passing data through APIs, debugging JWT tokens, or copying binary content into a JSON field. This guide shows you how to encode and decode Base64 instantly in your browser, including images.
When You Need Base64
- Embedding a small image directly in HTML or CSS as a data URI
- Sending binary data through a JSON API that only accepts text
- Decoding a Base64-encoded string from an API response or email header
- Inspecting the payload of a JWT token
- Storing file attachments in a database text field
How to Encode Text to Base64
Step 1: Open the tool
Go to the Base64 Encoder & Decoder and make sure the "Encode" tab is selected.
Step 2: Enter your text
Paste or type the text you want to encode. The tool handles Unicode text including Japanese, Chinese, Korean characters, and emoji.
Step 3: Click Encode
Click the "Encode →" button. The Base64-encoded string appears in the output panel. Click "Copy" to copy it to your clipboard.
How to Decode Base64 to Text
Step 1: Switch to Decode mode
Click the "Decode" tab.
Step 2: Paste the Base64 string
Paste the Base64-encoded string. If the input is a data URI (starts with data:image/...), the tool will automatically detect it and show an image preview.
Step 3: Click Decode
The decoded text appears in the output. For regular text, you can copy or download it. For images, you get a visual preview.
How to Convert an Image to Base64
Step 1: Click "Image → Base64"
Click the "Image → Base64" tab and select an image file (JPEG, PNG, WebP, GIF, SVG).
Step 2: Copy the data URI
The tool generates a complete data URI (e.g. data:image/png;base64,iVBOR...) that you can paste directly into HTML or CSS. A preview of the image is shown below the output.
Tips
- Base64 increases file size by ~33%. Only use it for small assets (icons, logos under 10KB). For larger images, use regular file URLs.
- Data URIs can be used in
<img src="data:...">or CSSbackground-image: url(data:...). - If you're debugging a JWT token, the payload is the middle section (between the two dots) — paste just that part to decode it.
FAQ
What is Base64 encoding?
Base64 is a way to represent binary data (like images or files) as a text string using 64 printable ASCII characters. It's commonly used in emails, data URIs, and APIs where binary data can't be sent directly.
Does Base64 encoding compress data?
No — Base64 actually increases size by about 33%. It's an encoding scheme, not compression. Use it when you need to embed binary data in text formats, not to reduce file size.
Is my data uploaded to a server?
No. All encoding and decoding happens entirely in your browser using JavaScript. Your data never leaves your device.
Can I encode non-ASCII text like Japanese or emoji?
Yes. Our tool handles Unicode text (including CJK characters and emoji) by encoding to UTF-8 first, then converting to Base64.
Try It Now
Ready to encode or decode? Open the Base64 Encoder & Decoder — it works entirely in your browser with no sign-up required.