Base64 encode and decode files with certutil

The built-in Windows tool that quietly handles base64 — certutil -encode / -decode.

Windowsbase64certutildeveloperLow risk
Run certutil -encode <in> <out> to base64-encode a file and certutil -decode <in> <out> to decode it back.

01Command

Command
$ certutil -encode in.txt out.b64 ; certutil -decode out.b64 restored.txt

02What it does

certutil's -encode/-decode operate on whole files, not strings, and the decoder also accepts output produced by other tools. Add -f to overwrite an existing output file. For hex dumps there's -encodehex/-decodehex, and within PowerShell a single string can also be encoded with [Convert]::ToBase64String when file round-trips are overkill.

03Risk

RiskLow risk
!Warning: certutil -decode writes raw bytes to the output path — decoding an untrusted file executes nothing by itself, but don't blindly decode-and-open attachments from unknown sources.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • certutil | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    Evidence: Microsoft documents certutil -encode and -decode converting files to and from base64, plus -encodehex/-decodehex for hexadecimal.
  • CERTUTIL - Windows CMD
    SS64 · technical · 2026-09-17
    Evidence: SS64 lists -encode/-decode base64 conversion and -decodehex, noting the -f flag to force overwrite of output files.

Last verified: 2026-09-17 · Category: Developer

06Related solutions