Base64 and URL encoding show up constantly in development work — in JWT tokens, HTTP headers, API payloads, query strings, and configuration files. Both are encoding schemes, not encryption, and both are easily reversed. Understanding when and why each is used saves a lot of debugging time.

Base64 encoding

Base64 converts binary data into a string of printable ASCII characters. It takes 3 bytes of input and produces 4 characters of output — roughly a 33% size overhead — but it allows binary data to travel safely through systems that only handle text.

When Base64 is used

  • Data URIs — embedding images or fonts directly in HTML or CSS: src="data:image/png;base64,...". Useful for small images that need to be inlined to avoid extra HTTP requests.
  • HTTP Basic Auth — the Authorization: Basic ... header encodes credentials as Base64. It's not encryption — it's just a way to include a colon-separated string in a header.
  • JWT tokens — the header and payload sections of JSON Web Tokens are Base64url-encoded (a variant that uses - and _ instead of + and /).
  • API payloads — encoding binary data (images, PDFs, audio) so it can be included in a JSON string field.
  • Email attachments — MIME encoding uses Base64 to include binary attachments in text-based email.

How to encode and decode

Use the Base64 Encoder to convert text to Base64, and the Base64 Decoder to convert it back. Both run locally in your browser — nothing is sent to a server.

Common Base64 debugging situations

  • Inspecting a JWT — paste the token, split on the dots, and decode each section to read the header and payload
  • Checking Basic Auth credentials — decode the value after "Basic " in an Authorization header
  • Reading an encoded API field — some APIs return binary data (images, files) as Base64 strings in JSON responses

A note on Base64 vs encryption

Base64 is not encryption. Anyone who sees a Base64 string can decode it instantly. Never use Base64 to "hide" sensitive information — use it only to encode data for transport or storage in systems that require text.

URL encoding

URLs can only contain a limited set of ASCII characters. Characters with special meaning in URLs (like &, =, ?, #, and spaces) or non-ASCII characters must be percent-encoded — replaced with a % followed by their hexadecimal value. A space becomes %20, an ampersand becomes %26, and so on.

When URL encoding matters

  • Query parameters — values containing &, =, or + in a URL query string must be encoded, or the server will misparse them
  • Redirect URLs — a URL used as the value of a redirect_to parameter must be fully encoded, or the ? and & in the redirect URL will be treated as part of the outer URL's query string
  • API requests — building API URLs with user-supplied values that might contain special characters
  • Debugging — decoding percent-encoded URLs to read them clearly

encodeURI vs encodeURIComponent

encodeURI encodes a full URL, preserving characters like /, :, ?, and & that have meaning in a URL. encodeURIComponent encodes everything including those characters — use it when encoding a value that will be embedded inside a URL (like a query parameter value or a redirect URL). The URL Encoder follows encodeURIComponent behaviour.

Encode and decode now

Frequently asked questions

Is Base64 the same as encryption?

No. Base64 is an encoding — it's trivially reversible by anyone. Never use it to protect sensitive data. Use it to encode binary data for transport through text-based systems.

Why does Base64 output sometimes end with = or ==?

Base64 processes 3 bytes at a time and produces 4 characters. When the input isn't a multiple of 3 bytes, padding characters (=) fill the gap to keep the output length a multiple of 4.

Why does a space encode as %20 instead of +?

Both %20 and + represent a space in URL encoding, but in different contexts. %20 is standard percent-encoding (RFC 3986); + is used in HTML form encoding (application/x-www-form-urlencoded). %20 is safer and more universally compatible.

Does anything get uploaded?

No. Encoding and decoding run locally in your browser using native JavaScript functions (btoa, atob, encodeURIComponent, decodeURIComponent). Nothing leaves your device.

← All articles

More articles