# File Type Identifier

> 在瀏覽器中從 magic number 辨識檔案的真實類型：真正格式對比副檔名、MIME 類型、能辨識容器的偵測（docx/apk/jar 其實是 ZIP）。線上免費，免上傳。

- URL: https://bytescope.dev/zh-Hant/file-type/
- Locale: zh-Hant · Also: [en](https://bytescope.dev/en/file-type.md) · [ja](https://bytescope.dev/ja/file-type.md)
- Runs: 檔案不會離開你的瀏覽器 — 全部在本機處理。
- Requires: Any modern browser (Chrome, Edge, Firefox, Safari), desktop and mobile.
- Updated: 2026-09-08

## What it does

拖入任何檔案 — 尤其是副檔名遺失、錯誤或未知的那種 — 這個工具會讀取它的前幾個位元組（必要時也讀尾端），從 magic number 特徵辨識真正的格式。你會得到偵測到的類型、它的 MIME 類型、正確的副檔名，以及一行說明這個格式究竟是什麼。一切都在你的瀏覽器中執行；檔案絕不會被上傳，所以對於你不信任的檔案也很安全。

副檔名會說謊，而這正是這個工具的重點：一個其實是 PNG 的 `.jpg`、一個藏在改名文件裡的 `.exe`，或一個完全沒有副檔名的神秘下載檔。當偵測到的類型與副檔名不符時，這個不符會被醒目標示出來，並附上建議的正確名稱。容器格式會再看一眼 — docx、xlsx、pptx、apk、jar 與 epub 骨子裡都是 ZIP 檔，所以工具會開啟容器的目錄來區分它們，對 RIFF 家族（WAV、AVI、WebP）也一樣。

文字檔會有自己的分析：編碼（UTF-8/16、是否有 BOM）、行尾（LF 對 CRLF），以及零散的 NUL 位元組是否暗示著二進位污染。批次模式能一次辨識許多檔案，而任何無法辨識的東西都會以 hex 顯示它的前 64 個位元組，並可一鍵跳進 Hex 編輯器手動檢視。

## Limits

Does not open, convert or repair the file; it identifies the real format from the magic bytes.

## Machine output

Copy JSON copies an envelope `{ tool, url, generatedAt, userAgentHint, result }`. `tool` is `"file-type"`; `result` is the magic-byte identification below. The file name and any leftover file bytes (hex dump) are omitted.

- `identified` (boolean) — `false` = no detector matched (unidentified). `true` = a detector matched a known format. There is no "unknown format" id.
- `formatId` (string | null) — Stable format id (e.g. `"png"`). `null` = unidentified.
- `formatName` (string | null) — Display name. `null` = unidentified.
- `mime` (string | null) — Detected MIME type. `null` = unidentified.
- `extensions` (string[]) — Canonical extensions without a leading dot, on-screen order. Empty when unidentified or the type has none.
- `description` (string | null) — One-line format description. `null` = unidentified.
- `confidence` (string | null) — `"certain"` | `"likely"` | `"weak"`. `null` = unidentified.
- `extensionStatus` (string) — `"match"` | `"mismatch"` | `"no-extension"` | `"unknown"`.
- `extensionActual` (string | null) — Lowercase extension from the name, no dot. `null` = the name had no extension.
- `suggestedExtension` (string | null) — Canonical extension to rename to. `null` unless status is `"mismatch"`.
- `isDangerousMismatch` (boolean) — Executable content with a mismatched extension.
- `textEncoding` (string | null) — `"utf-8"` | `"utf-8-bom"` | `"utf-16le-bom"` | `"utf-16be-bom"` | `"ascii"` | `"unknown-binary"`. `null` = not classified as text, so encoding was not analysed. `"unknown-binary"` = analysed, charset unnamed.
- `lineEndings` (string | null) — `"lf"` | `"crlf"` | `"cr"` | `"mixed"` | `"none"`. `null` = not analysed.
- `hasNulBytes` (boolean | null) — `null` = not analysed; `false` = analysed, no NUL; `true` = NULs present.
- `byteLength` (number | null) — File size in bytes. `null` = size was not supplied.

## FAQ

### 辨識我的檔案時它會被上傳嗎？

不會。只有前幾 KB（某些容器格式還會讀尾端）會在你的瀏覽器本機讀取，用來比對特徵資料庫。檔案絕不離開你的裝置 — 這正是你在檢查可疑檔案時想要的。

### 什麼是 magic number？

大多數檔案格式的開頭都有一段固定的位元組特徵 — PNG 檔以 89 50 4E 47 開頭，ZIP 壓縮檔以 50 4B 開頭。這些「magic number」不論檔名為何都能辨識出真正的格式，這也是這個工具（以及 Unix 的 `file` 指令）能抓出被錯誤標示檔案的原理。

### 為什麼我的 .docx 顯示成 ZIP 檔？

因為它就是 — docx、xlsx、pptx、apk、jar 與 epub 全都是含有特定內容的 ZIP 容器。工具會查看 ZIP 目錄裡的關鍵項目（Office 的 [Content_Types].xml、APK 的 AndroidManifest.xml）來回報具體的格式，而不只是說「ZIP」。

### 它能告訴我一個檔案是否危險嗎？

它能藉由揭露真實類型，抓出常見的偽裝伎倆 — 一個被改名成看似文件的可執行檔。那是有用的第一道檢查，但它不是惡意軟體掃描：一個類型如實的檔案仍然可能含有惡意內容。

### 如果檔案無法被辨識怎麼辦？

未知的檔案會以 hex 顯示它的前 64 個位元組，讓你自己檢視結構，並可一鍵移交給 Hex 編輯器。特徵會隨時間持續新增，所以無法辨識的格式對我們來說也是擴充資料庫的訊號。
