Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchNo. JavaScript’s atob() accepts valid Base64 with its trailing = padding omitted. But a lone trailing = is not a general substitute for correct padding: for example, atob("YQ=") throws an InvalidCharacterError.
When does atob() accept or reject padding?
The HTML Standard defines atob() using the Infra Standard’s forgiving Base64 decoder. That decoder removes ASCII whitespace first. If the remaining input’s length is divisible by four, it strips one or two trailing equals signs before decoding. If the length has a remainder of one when divided by four, decoding fails. Characters outside the Base64 alphabet are also rejected.
As an Amazon Associate I earn from qualifying purchases.
| Input | Result | Why |
|---|---|---|
atob("YQ") |
Accepted; decodes to the byte for a. |
Valid Base64 can omit padding. |
atob("YQ==") |
Accepted; decodes to the byte for a. |
Conventional two-character padding is valid. |
atob("YQ=") |
Throws InvalidCharacterError. |
The length is not divisible by four, so the equals sign is not stripped and is invalid in that position. |
| Any input with post-whitespace length congruent to 1 modulo 4 | Rejected. | That length cannot be decoded by the forgiving Base64 algorithm. |
These outcomes follow the Infra Standard’s forgiving Base64 algorithm; the examples illustrate its rules rather than report separate browser tests. The HTML Standard’s atob() steps say that failure from this decoder causes an InvalidCharacterError DOMException.
Why can omitted padding work while half-padding fails?
Padding is optional in the inputs accepted by atob(), but padding characters that are present still have to fit the decoder’s rules. The decoder strips trailing equals signs only when the input length after whitespace removal is divisible by four. In "YQ=", the length is three, so the equals sign remains and is rejected. Omitting it entirely gives "YQ", which is valid.
#1 Best Overall
Does atob() return decoded text?
No. atob() returns a binary string: each character represents one byte, with a code point from U+0000 through U+00FF. It does not automatically interpret those bytes as UTF-8 or return Unicode text. For byte-oriented work, MDN points to Uint8Array.fromBase64() as an alternative; see its atob() reference.
The related btoa() function also works with byte values represented by single-byte characters, not arbitrary Unicode strings. Characters above U+00FF cause an InvalidCharacterError. To Base64-encode or decode Unicode text, convert between the text and bytes explicitly, typically using UTF-8. MDN explains this limitation in its btoa() reference.
Quick Recap
Best Value
Rank #4
Rank #2
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Free tools Windows power users keep installed
One-click scans. No signup required.




