Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

FYI browsers have built in functions for decoding base64, btoa() and atob(). Although I can never remember which is which.


Guessing from the names:

btoa() should be base64 to ascii

atob() should be ascii to base64

Edit: it’s other way around, lolwut. https://developer.mozilla.org/en-US/docs/Web/API/atob


No-one uses these often, and you have a 50% of guessing right every time!


This other page has some more details

> The btoa() method creates a Base64-encoded ASCII string from a binary string (i.e., a string in which each character in the string is treated as a byte of binary data).

https://developer.mozilla.org/en-US/docs/Web/API/btoa

So the naming makes sense after all.

btoa() is binary to (base64 encoded) ascii.

But I’m still not gonna remember this either :^)




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: