Base64 Encoder & Decoder (UTF-8 & URL-Safe) — Free Online Tool

Encode and decode UTF-8 text, JWT-ready URL-safe Base64, and files to Data URIs instantly in your browser with live validation and zero server uploads.

100% Client-Side • Your data stays in your browser
How to use & FAQ
Loading tool...

Base64 Encoder

Base64 encoding is everywhere in modern web development: HTTP Basic Authentication headers, JSON Web Tokens (JWT), inline SVG and PNG Data URIs in CSS/HTML, webhook signatures, and binary attachments inside JSON APIs. Yet JavaScript’s legacy btoa() and atob() functions famously crash on accented characters and emojis unless you handle UTF-8 byte encoding properly. Our free Base64 Encoder & Decoder handles full UTF-8 Unicode, URL-safe Base64, and local file-to-Data-URI conversion right in your browser. Everything runs 100% client-side with live validation and instant byte-size feedback, meaning you can safely decode API tokens, authorization headers, or configuration blobs without ever sending them across the network.

How to Use This Tool

  1. 01 Select Encode to turn plain UTF-8 text into Base64, or Decode to convert a Base64 string (or Data URI) back into readable text.
  2. 02 Enable "URL-safe (-_, no padding)" when generating values for URLs, query parameters, filenames, or JWT payloads (RFC 4648 §5).
  3. 03 Paste your text or Base64 payload into the left editor—the output updates immediately as you type, along with live validation and byte-size stats.
  4. 04 Click Swap anytime to flip the output into the input and switch between Encode and Decode modes.
  5. 05 To convert an image, SVG, font, or small document into an inline Data URI, use the File to Base64 / Data URI panel below and click Copy Data URI or Copy Base64.
  6. 06 Click Copy Output to copy your encoded or decoded string to the clipboard in one click.

How It Works

Standard Base64 (RFC 4648) represents every 3 bytes (24 bits) of binary data as 4 printable ASCII characters drawn from A–Z, a–z, 0–9, +, and /, using = as trailing padding when the byte length is not a multiple of 3. Because text can contain multibyte Unicode characters (like accented letters or emojis), this tool first converts strings to exact UTF-8 byte sequences using TextEncoder before encoding, and validates UTF-8 integrity via TextDecoder when decoding. When URL-safe mode is active, + and / are replaced with - and _ and = padding is omitted so the output can be placed directly inside URLs and JWT segments without percent-encoding. File encoding reads the selected file via the browser’s local File API into a Uint8Array—no file is ever uploaded to any server.

Practical Examples

Encoding UTF-8 Text with Accents and Emojis

Input
                      Olá mundo! 🚀
                    
Output
                      T2zDoSBtdW5kbyEg8J+agA==
                    

Unlike plain btoa(), which throws an InvalidCharacterError on "á" or "🚀", UTF-8 byte encoding cleanly preserves every Unicode character.

URL-Safe Base64 for Tokens & Query Strings

Input
                      subjects?_d=1&x=>> (URL-safe enabled)
                    
Output
                      c3ViamVjdHM_X2Q9MSZ4PT4-
                    

Replacing + and / with - and _ and stripping = padding guarantees the encoded token never breaks URL routing or query parsers.

Inlining an SVG Icon as a Data URI

Input
                      File: icon.svg (<svg/>)
                    
Output
                      data:image/svg+xml;base64,PHN2Zy8+
                    

Small icons or placeholders can be embedded directly inside HTML img src or CSS background-image rules to eliminate extra HTTP requests.

Tips & Best Practices

  • Remember that Base64 is an encoding, NOT encryption—anyone can decode Base64 instantly, so never rely on it to hide secrets.
  • Base64 increases payload size by roughly 33% (4 output characters per 3 input bytes); only inline small assets as Data URIs.
  • When decoding a JWT payload segment, you can paste it directly into Decode mode—our decoder automatically handles URL-safe characters and missing = padding.
  • You can paste a full Data URI (data:text/plain;base64,...) directly into Decode mode; the prefix is stripped automatically.
  • All encoding and decoding happen offline in browser memory, making it safe for private headers and internal tokens.

Frequently Asked Questions

Is Base64 a form of encryption?

No. Base64 is a reversible text encoding designed to transport binary data safely over text-only channels. It provides zero confidentiality or security on its own.

Does this tool send my text or uploaded files to a server?

No. Both text encoding/decoding and file-to-Data-URI conversion run 100% locally inside your browser using JavaScript Web APIs.

What is URL-safe Base64 (Base64URL)?

URL-safe Base64 (defined in RFC 4648 Section 5) swaps "+" for "-" and "/" for "_" and removes trailing "=" padding so the string can safely appear in URLs, cookies, and JWT tokens without escaping.

Why does Base64 make my data about 33% larger?

Base64 maps every 3 binary bytes (24 bits) onto 4 ASCII characters (6 bits each), which introduces a fixed 4/3 (~33.3%) size overhead.

Can this tool decode Base64 with Portuguese, Spanish, or emoji characters?

Yes. It encodes and decodes via standard UTF-8 byte arrays (TextEncoder/TextDecoder), so accented characters, symbols, and emojis round-trip accurately.

Related Tools