Reference · 6 min read

Base64 file signatures.

Most file formats begin with a fixed sequence of “magic bytes”. Encode those bytes and you get a fixed Base64 prefix, so you can tell a PDF from a PNG from a Windows executable without decoding anything. The table below covers more than 60 formats.

Updated 9 November 2026

Quick answer

Look at the first few characters. JVBERi0 is a PDF, iVBORw0KGgo a PNG, /9j/ a JPEG, R0lGOD a GIF, UklGR a RIFF file (WebP, WAV, AVI), UEsDB a zip (including .docx, .xlsx, .jar, .apk), H4sI gzip, TVqQ a Windows .exe, and eyJ JSON (every JWT starts with it). Find any other format in the table below.

How it works

Base64 turns every 3 bytes into 4 characters, always starting from the first byte. So the first 3 bytes of a file always decide the first 4 characters, the next 3 decide the next 4, and so on. A PNG file always begins with the 8 bytes 89 50 4E 47 0D 0A 1A 0A, so its Base64 always begins with iVBORw0KGgo, whatever the image shows.

Because 8 bytes don't divide evenly into 6-bit characters, only the characters built entirely from signature bytes are fixed. The table shows exactly those. (PNG's 8 bytes fix 10 characters; the 11th mixes in the next byte, which in a PNG is always 0, so iVBORw0KGgo is reliable in practice.)

Signatures at an offset

Some formats put their signature a few bytes in. RIFF files (WebP, WAV, AVI) start with RIFF, then a 4-byte file size, then the real type. ISO media files (MP4, MOV, HEIC, AVIF) start with a 4-byte box size and then ftyp. The size bytes change from file to file, so the characters covering them change too. For these, the table gives the fixed characters and the position where they appear, counting from 1. For example, a WebP file has UklGR at the start and RUJQ at character 13.

The table

Base64 prefixes are computed from the magic bytes shown and checked against sample files. Text formats (SVG, HTML, JSON, scripts) have no true magic number, so their prefixes only hold when the file starts exactly as shown.

FormatExtensionsMagic bytes (hex)Base64 starts withNotes
PDF.pdf25 50 44 46 2DJVBERi0Followed by the version, e.g. %PDF-1.7 or %PDF-2.0. Both give JVBERi0.
Zip and zip-based formats.zip .docx .xlsx .pptx .odt .epub .jar .apk50 4B 03 04UEsDBOffice Open XML, OpenDocument, EPUB, Java and Android packages are all zip files.
Zip (empty archive).zip50 4B 05 06UEsFB
Legacy Microsoft Office (OLE2).doc .xls .ppt .msg .msiD0 CF 11 E0 A1 B1 1A E10M8R4KGxGuCompound File Binary format.
Rich Text Format.rtf7B 5C 72 74 66e1xydG
PostScript.ps .eps25 21 50 53JSFQU
PNG.png89 50 4E 47 0D 0A 1A 0AiVBORw0KGgoFull 8-byte signature; the next byte is always 00.
JPEG.jpg .jpegFF D8 FF/9j/URL-safe encoding turns this into _9j_.
GIF (89a).gif47 49 46 38 39 61R0lGODlh
GIF (87a).gif47 49 46 38 37 61R0lGODdh
WebP.webp52 49 46 46
57 45 42 50 @ byte 8
UklGR
RUJQ at char 13
RIFF container; bytes 4 to 7 are the file size.
BMP.bmp42 4DQkOnly two bytes, so short text strings can also start with Qk.
ICO.ico00 00 01 00AAABA
CUR (cursor).cur00 00 02 00AAACA
TIFF (little-endian).tif .tiff49 49 2A 00SUkqAAlso the start of many camera RAW files (.cr2, .nef, .dng).
TIFF (big-endian).tif .tiff4D 4D 00 2ATU0AK
Photoshop.psd38 42 50 53OEJQU
SVG (no XML declaration).svg3C 73 76 67PHN2ZText format: leading whitespace or a comment changes the prefix.
XML / SVG with declaration.xml .svg3C 3F 78 6D 6CPD94bWText format.
AVIF.avif66 74 79 70 61 76 69 66 @ byte 4eXBhdmlm at char 9ISO media box: bytes 0 to 3 are the box size, which varies.
HEIC.heic66 74 79 70 68 65 69 63 @ byte 4eXBoZWlj at char 9Same box structure as AVIF and MP4.
JPEG 2000.jp200 00 00 0C 6A 50 20 20 0D 0A 87 0AAAAADGpQICANCocK
JPEG XL (codestream).jxlFF 0A/w
QOI.qoi71 6F 69 66cW9pZ
MP3 with ID3 tag.mp349 44 33SUQzMP3 files without a tag start with a frame header instead (often FF FB, Base64 //).
FLAC.flac66 4C 61 43ZkxhQ
Ogg (Vorbis, Opus).ogg .oga .opus4F 67 67 53T2dnU
WAV.wav52 49 46 46
57 41 56 45 @ byte 8
UklGR
QVZF at char 13
RIFF container like WebP.
AVI.avi52 49 46 46
41 56 49 20 @ byte 8
UklGR
Vkkg at char 13
RIFF container.
AIFF.aiff .aif46 4F 52 4D
41 49 46 46 @ byte 8
Rk9ST
SUZG at char 13
MIDI.mid .midi4D 54 68 64TVRoZ
MP4.mp4 .m4v66 74 79 70 69 73 6F 6D @ byte 4eXBpc29t at char 9Brand varies (isom, mp42, avc1 ...); look for the ftyp box.
M4A audio.m4a66 74 79 70 4D 34 41 20 @ byte 4eXBNNEEg at char 9
QuickTime.mov66 74 79 70 71 74 20 20 @ byte 4eXBxdCAg at char 9
Matroska / WebM.mkv .webm1A 45 DF A3GkXfoEBML header.
Flash video.flv46 4C 56RkxW
Gzip.gz .tgz1F 8B 08H4sIVery common inside JSON, HTTP and Kubernetes secrets.
Bzip2.bz242 5A 68Qlpo
XZ.xzFD 37 7A 58 5A 00/Td6WFoA
7-Zip.7z37 7A BC AF 27 1CN3q8rycc
RAR.rar52 61 72 21 1A 07UmFyIRoHRAR 4 continues with 00, RAR 5 with 01 00.
Zstandard.zst28 B5 2F FDKLUv/
LZ4 frame.lz404 22 4D 18BCJNG
Microsoft Cabinet.cab4D 53 43 46TVNDR
Tar (POSIX).tar75 73 74 61 72 @ byte 257c3Rhc at char 345The signature is 257 bytes in, so it never appears at the start.
Windows executable (PE).exe .dll .sys4D 5A 90 00TVqQAMZ header with the usual DOS stub. Very common in malware analysis.
ELF (Linux executable)(none), .so, .o7F 45 4C 46f0VMR
Mach-O 64-bit (macOS)(none), .dylibCF FA ED FEz/rt/
Java class / Mach-O universal.classCA FE BA BEyv66vBoth formats share this magic number.
WebAssembly.wasm00 61 73 6DAGFzb
Android DEX.dex64 65 78 0AZGV4C
Script with shebang.sh .py23 21 2FIyEvText format.
Windows shortcut.lnk4C 00 00 00 01 14 02 00 00 00 00 00TAAAAAEUAgAAAAAA
WOFF.woff77 4F 46 46d09GR
WOFF2.woff277 4F 46 32d09GM
TrueType.ttf00 01 00 00AAEAA
OpenType (CFF).otf4F 54 54 4FT1RUT
SQLite database.db .sqlite53 51 4C 69 74 65 20 66 6F 72 6D 61 74 20 33 00U1FMaXRlIGZvcm1hdCAzA
Parquet.parquet50 41 52 31UEFSM
pcap capture (little-endian).pcapD4 C3 B2 A11MOyo
pcapng capture.pcapng0A 0D 0D 0ACg0NC
Windows registry hive(none), .dat72 65 67 66cmVnZ
PEM text.pem .crt .key2D 2D 2D 2D 2D 42 45 47 49 4ELS0tLS1CRUdJTBase64 of a PEM file, i.e. encoded twice.
DER certificate or key.der .cer30 82MIASN.1 SEQUENCE with a two-byte length; in practice usually MII.
JSON object.json7B 22eyJWhen the first key starts with a letter. Every JWT starts with eyJ.
HTML document.html3C 21 44 4F 43 54 59 50 45PCFET0NUWVBFText format; case and whitespace change the prefix.
UTF-8 text with BOM.txt .csvEF BB BF77u/Common in CSV files exported from Excel.
UTF-16LE text with BOM.txtFF FE//

Things that change the prefix

  • URL-safe encoding. + and / become - and _, so a JPEG starts with _9j_ and an XZ file with _Td6WFoA. Normalise before you compare.
  • A data URI header. data:image/png;base64, comes before the Base64. Compare from the character after the comma.
  • Line breaks and whitespace. MIME and PEM wrap Base64 every 64 or 76 characters, which can split a long prefix. Remove whitespace first.
  • Double encoding. If a string decodes to more Base64, its prefix looks like the Base64 of a Base64 prefix. A PDF encoded twice starts with SlZCRVJp (the encoding of JVBERi).
  • Compression or encryption. Encrypted data has no signature at all, and compressed data only shows the compressor's signature (gzip, zstd), not the file inside.

Checking the prefix in code

Python

PREFIXES = {
    "JVBERi0": "pdf", "iVBORw0KGgo": "png", "/9j/": "jpg", "R0lGOD": "gif",
    "UklGR": "riff", "UEsDB": "zip", "H4sI": "gzip", "TVqQ": "exe", "eyJ": "json",
}

def sniff(b64: str) -> str:
    s = b64.split(",", 1)[-1].strip().replace("-", "+").replace("_", "/")
    for prefix, kind in PREFIXES.items():
        if s.startswith(prefix):
            return kind
    return "unknown"

JavaScript

const PREFIXES = { JVBERi0: "pdf", iVBORw0KGgo: "png", "/9j/": "jpg", R0lGOD: "gif",
  UklGR: "riff", UEsDB: "zip", H4sI: "gzip", TVqQ: "exe", eyJ: "json" };

function sniff(b64) {
  const s = b64.slice(b64.indexOf(",") + 1).trim().replace(/-/g, "+").replace(/_/g, "/");
  return Object.entries(PREFIXES).find(([p]) => s.startsWith(p))?.[1] ?? "unknown";
}

Linux / macOS

head -c 16 input.b64; echo           # look at the prefix
base64 --decode input.b64 | file -     # let file(1) read the magic bytes

PowerShell

$s = (Get-Content -Raw .\input.b64).Trim()
if ($s.StartsWith("JVBERi0")) { "PDF" } elseif ($s.StartsWith("iVBORw0KGgo")) { "PNG" } else { $s.Substring(0, 16) }

A prefix match is a strong hint, not proof: a short signature such as BMP's Qk also matches any text that starts with “BM”. When it matters, decode and check the bytes. Smart Detect and the decoder do this for you in the browser.

Decode a file of a known type

Once you know the type, use the matching tool to preview and download it: Base64 to PDF, PNG, JPG, SVG, or any image. For other formats, the decoder's download button saves the raw bytes.


Published 9 November 2026. Spot an error? Email contactus@base64decode.tools.

Frequently asked

Common questions.

It is the Base64 encoding of %PDF-, the signature every PDF file starts with. The string is a Base64-encoded PDF document.

A PNG image. iVBORw0KGgo is the Base64 form of the 8-byte PNG signature 89 50 4E 47 0D 0A 1A 0A.

UEsDB is the Base64 form of PK\x03\x04, the zip signature. Word, Excel and PowerPoint files (.docx, .xlsx, .pptx), EPUB books, Java .jar and Android .apk files are all zip archives, so they start with UEsDB too.

A JWT header is a JSON object beginning with {" followed by a letter. Those bytes always encode to eyJ in Base64.

Usually, yes. Formats with a fixed signature at byte 0 always produce the same leading Base64 characters. Formats with signatures further in (RIFF, MP4, tar) produce fixed characters at a known position instead. Text formats and encrypted data have no reliable signature.

Keep going

Related guides and tools.