safepaste base64

Base64 encoder and decoder

Paste into either side. Your data is decoded or encoded directly in this tab, and is never sent anywhere.

Text

Base64

Alphabet
Output

You can also drop a file here to encode it. It is contained in the tab and never uploaded.

What happens to what you paste

Nothing. It is converted in this browser tab and then it is gone when you close the tab. SafePaste has no account, no database and no analytics, so there is nothing for it to be stored in.

This is enforced, not promised

The page includes a Content Security Policy of connect-src 'none'. That makes fetch, XMLHttpRequest, WebSocket, EventSource and sendBeacon fail in the browser itself, whatever the code on this page tries to do. Images and fonts are restricted to data that is already inside the file, and form-action 'none' prevents all form submission.

You do not have to take our word for it. Open your browser's developer tools, watch the Network tab while you use the page, and confirm that it stays empty after the page itself has loaded.

What the host can see

This page is served by Cloudflare Pages. Like any web server, it sees the request for the page itself: an IP address, a user agent, a timestamp. That happens before any of this page's code runs and it is the same for every website you visit. What it does not see is anything you paste, because nothing you paste is ever part of a request.

No cookies, no storage, no trackers

The two links that leave

The footer links to Flytrap Industries and to a Stripe donation page. Neither is contacted unless you click it. They carry no query string and no referrer, so following one tells the destination nothing about what you were doing here. If you do donate, Stripe handles that payment under its own privacy policy and SafePaste never sees your card details.

Working offline

Save this page to disk and open it again. It is a single self-contained file, so it works with no network at all, including on a machine that has never been connected to one.

This policy describes the page you are reading. It is part of the same file, so the copy you save to disk carries it too.

How base64 works

Base64 does not encrypt or compress anything. It takes exactly the same bits and writes them down using a smaller alphabet, made only of characters that survive being pasted into an email, a web address or a JSON file. Here is the whole idea, worked through with the word abc.

Every letter is eight bits

A computer stores each of these letters as one byte, which is a row of eight ones and zeros. Which row belongs to which letter is fixed by a standard table called ASCII.

Cut the same bits into sixes

Base64 has 64 characters, and 64 is exactly how many different rows six bits can make. So the same 24 bits are kept in the same order and cut into groups of six instead of eight. Nothing is added and nothing is thrown away. The colours and underlines show how each letter's bits end up spread across the new groups.

Look each group up

Each group of six bits is a number between 0 and 63. That number is a position in the base64 alphabet, and the character at that position is what gets written down.

abc becomes YWJj. Three bytes became four characters.

The whole base64 alphabet, with each character's position. The four used for abc are highlighted.
  1. A0
  2. B1
  3. C2
  4. D3
  5. E4
  6. F5
  7. G6
  8. H7
  9. I8
  10. J9 (used for abc)
  11. K10
  12. L11
  13. M12
  14. N13
  15. O14
  16. P15
  17. Q16
  18. R17
  19. S18
  20. T19
  21. U20
  22. V21
  23. W22 (used for abc)
  24. X23
  25. Y24 (used for abc)
  26. Z25
  27. a26
  28. b27
  29. c28
  30. d29
  31. e30
  32. f31
  33. g32
  34. h33
  35. i34
  36. j35 (used for abc)
  37. k36
  38. l37
  39. m38
  40. n39
  41. o40
  42. p41
  43. q42
  44. r43
  45. s44
  46. t45
  47. u46
  48. v47
  49. w48
  50. x49
  51. y50
  52. z51
  53. 052
  54. 153
  55. 254
  56. 355
  57. 456
  58. 557
  59. 658
  60. 759
  61. 860
  62. 961
  63. +62
  64. /63

When the bytes run out

Base64 works three bytes at a time, because three bytes are 24 bits and 24 bits cut into exactly four groups of six. Text does not always come in threes, though. The word ab is only 16 bits: two full groups, and four bits left over.

Zeros are added to finish the last group, which gives a third character. The fourth character has nothing left to describe, so it is written as =. The equals sign carries no data. It only says that the last group came up short.

The two shaded zeros were added to finish the third group. They are not part of ab.

Text Bytes Base64 Padding
abc3YWJjNone needed
ab2YWI=One =
a1YQ==Two =

One = means the last group held two bytes, and two mean it held only one. Because padding carries no data, plenty of formats leave it off, including the tokens many websites use to keep you signed in. This tool notices when it is missing and puts it back.

A few more things worth knowing