DEV Community

Ky Huynh
Ky Huynh

Posted on

1 1

How to encode and decode file to base64 offline

Although there are a number of websites that allow to convert file to base64 and vice versa. However, it could leads to data leak issue if these data from your working project.

Therefore, I would like to introduce a tip to convert file to base64 (and vice versa) offline.

1) Encode file (ex: pdf) to base64:

base64 -w 0 test1.pdf

Image description

2) Encode a file to base64 and write it to file:

base64 -w 0 test1.pdf > test1.txt

3) Decode base64 to file:

base64 -d test1.txt > test1.pdf

Tool need to use:

  1. Linux: use the default cmd
  2. Window: use the git bash which I believe all the developers already installed

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more