Skip to content
ToolsOnDuty - free online tools

Search tools

Loading tool search...

Developer Guides

Base64 vs URL Encoding: What Is the Difference?

Understand what Base64 and percent encoding are designed to do, why neither provides secrecy, and when each belongs in a URL.

By ToolsOnDuty Editorial Team

Plain text transformed with Base64 and URL percent encoding

Base64 and URL encoding both transform data into a transport-friendly representation, but they solve different problems. Base64 represents bytes using a limited text alphabet. URL percent encoding escapes characters that have special meaning inside a web address.

Neither technique hides information. Anyone who recognizes the format can reverse it. Use encryption and proper access control when confidentiality is required.

What Base64 does

Base64 converts binary data into ASCII characters. It is common in email attachments, data URLs, API payloads, and tokens where a text-only channel must carry bytes. Standard Base64 output can contain plus, slash, and equals characters.

The encoded result is larger than the original byte data, typically by about one third before surrounding protocol overhead. It is a compatibility format, not compression.

Base64 exampletext
Hello -> SGVsbG8=
Base64 encoder showing plain text input and its encoded result
Base64 changes the representation of text; it does not conceal the original value.

What URL encoding does

URLs reserve characters such as question marks, ampersands, slashes, and equals signs for structure. Percent encoding represents a character's UTF-8 bytes as percent signs followed by hexadecimal values. A space is commonly encoded as %20 in a URL path.

Encode individual query parameter values with a structured URL API rather than encoding an entire URL blindly. Encoding structural separators can change how the address is interpreted.

Percent-encoding exampletext
hello world -> hello%20world

Choose by the value you need to transport

For a query value such as A+B & C, use percent encoding so the literal plus and ampersand do not become query structure or a form-style space. The URL Encoder produces A%2BB%20%26%20C. Put that value under the intended parameter name, not in place of the complete address. A structured URL API is preferable when assembling an address programmatically.

For Hello, Base64 produces SGVsbG8= while URL encoding leaves Hello unchanged because its letters do not need escaping. With café, the UTF-8 text helpers produce Y2Fmw6k= and caf%C3%A9 respectively. Both reverse to the same original text, but the output formats answer different transport requirements.

If an API explicitly requires Base64 data inside a query parameter, the two operations can be layered. Base64-encode the text first, then percent-encode that encoded value when assembling the URL. For Hello this makes SGVsbG8%3D. Do not add another encoding layer when a URL API already escapes the parameter for you; that can change %3D into %253D.

A value is encoded; the URL separators are not.text
Original: A+B & C
Encoded query value: A%2BB%20%26%20C
Example address: https://example.com/?q=A%2BB%20%26%20C

Base64 inside URLs

Standard Base64 characters can conflict with URL and filename syntax. Base64url replaces plus with hyphen, slash with underscore, and often omits padding. JWT segments use this URL-safe variant.

Do not assume every Base64 decoder accepts Base64url automatically. Normalize the alphabet and padding or use a tool designed for the expected variant.

Do not confuse encoding with security

An encoded API key is still an exposed API key. Encoding does not add a secret key, authentication, integrity, or access control. Avoid putting sensitive values in URLs because addresses can appear in browser history, server logs, analytics, and referrer headers.

Check the reverse operation and its limits

Use synthetic input and confirm that decoding returns the exact original, including accents and punctuation. The URL decoder uses decodeURIComponent: hello+world stays hello+world, not hello world. A plus-to-space rule belongs to form-style query parsing and is not applied automatically by this text decoder.

Malformed percent escapes such as %ZZ produce an error. A valid Base64 byte sequence may also fail when those bytes are not valid UTF-8 text: /w== represents byte FF but cannot be decoded as a UTF-8 sentence by the standard text helper. Use a suitable byte-oriented workflow for arbitrary binary data rather than assuming that a text decoder can preview any file.

The text transformations run in the browser, but loading the site and its libraries can still use the network. Decoding a token does not verify its issuer or signature. Review decoded content before copying or sharing it, and never use a successful round trip as a confidentiality or trust verdict.

Apply the steps from this guide directly in your browser.

Frequently asked questions

Is Base64 encryption?

No. Base64 is a reversible representation of bytes and provides no secrecy.

Why does Base64 sometimes end with equals signs?

Equals signs are padding used to complete the final encoded group. Some variants, including many Base64url uses, omit that padding.

Should I URL-encode a complete URL?

Usually no. Encode the individual path or query values with a URL API so structural separators retain their meaning.