Decodex

DECODEX · BASE64

Base64 vs Base64URL: differences, padding and decoding examples

Follow a Base64 value through a query string. This guide isolates transport damage from errors in the original value.

Why URLs and form fields cause problems

In application/x-www-form-urlencoded data, a + character can be interpreted as a space. A / character can also conflict with a path separator when embedded in a URL path. Base64URL avoids these two characters. It does not replace proper URL construction: use URLSearchParams or an appropriate URL API instead of concatenating unescaped values. If a + was already replaced with a space, a decoder cannot reliably reconstruct the missing data.

How to convert between the formats

To create unpadded Base64URL, first encode the original bytes as Base64, replace + with - and / with _, then remove only trailing = characters if the target protocol allows it. For decoding, normalize the alphabet and add the required trailing padding. Do not remove internal characters or assume every service accepts both forms. Decodex encodes standard padded Base64; it accepts Base64URL on the decoding page.

JWT segments are not proof that a token is safe

The header and payload of a signed JWT commonly use unpadded Base64URL. Decoding a segment can show its text, but it does not verify a signature, expiry or permissions. The signature segment is binary and should not be expected to decode as UTF-8. This page does not validate JWTs; never share a real access token just to test decoding.

Verified experiments

Input / operationExpected resultBrowser result
?v=8J+YgA==8J YgA==Not run
URLSearchParams.set("v", "8J+YgA==")8J+YgA==Not run
8J-YgA😀Not run
SGVsbG8%3DHelloNot run

What the results mean

Parsing a raw query converts + into a space. Setting the value with URLSearchParams preserves it across serialization. Base64URL avoids +, but does not replace URL construction or restore data already lost.

How to reproduce

Run the checks and compare raw-query with safe-query. In the browser console inspect new URLSearchParams("v=8J+YgA==").get("v"). Rebuild the URL from the original value using set(), rather than replacing every space with +.

const p = new URLSearchParams();
p.set("v", "8J+YgA==");
console.log(p.toString()); // v=8J%2BYgA%3D%3D
console.log(new URLSearchParams(p.toString()).get("v")); // 8J+YgA==

Base64 →

Verification method

These fixed, public fixtures run against the same file codec and character codecs used by the converter. The JavaScript cases additionally check browser-native btoa, TextEncoder, URLSearchParams and SHA-256. Expected outputs are published before any script runs; the button shows actual results in your browser. No input is uploaded.

JavaScript · guide-cases.js · JavaScript · file-codec.js

Scope and limitations

Checked on 2026-10-21. This is a correctness check with small fixtures and one 100,000-character case, not a speed benchmark or a guarantee for every file. The four-byte file is synthetic binary data, not a PNG or PDF. SHA-256 equality checks byte preservation; it does not establish that a file is safe to open. Results can depend on browser support.

References

Choose a guide for your problem

More online tools

Convert images, test your keyboard, and use other handy tools in your browser.

Explore Altomono tools