MIME type catalog
The MIME type catalog gives UploadThing one shared set of file type names and extension rules. It supports route configuration, browser file filters, and server-side checks so that clients and servers classify the same file in the same way. It is a supporting part of the shared foundations, with related runtime helpers described in shared runtime utilities.
Catalog purpose
The catalog maps a MIME type to its known file extensions. A MIME type is the standard string that describes file content, such as image/png; an extension is the suffix in a file name, such as png. The catalog uses both forms because a browser may provide a MIME type and may also provide no useful type at all.
The data is grouped by broad content family. The groups make the catalog easier to use in browser filters while the combined catalog remains available for exact lookup.
| Group | Scope | Typical route use |
|---|---|---|
| Application | Documents, archives, code, and other application data | Exact types such as application/pdf or application/json |
| Audio | Sound and music files | Broad audio routes or exact audio MIME types |
| Image | Raster, vector, and image-editor files | Broad image routes or exact image MIME types |
| Text | Plain text, markup, and source files | Broad text routes or exact text MIME types |
| Video | Moving-image and container files | Broad video routes or exact video MIME types |
| Miscellaneous | Font, model, chemical, message, and other less common types | Exact MIME types when a broad UploadThing alias is not enough |
Application group
The application group covers data that is not primarily audio, image, text, or video. It includes common document and package formats as well as registered vendor formats, so it is the main source for exact application MIME type keys. application.ts defines this group as a MIME-to-extension map; entries such as application/pdf show the shape used by the catalog. (packages/mime-types/src/application.ts#L1-L10, packages/mime-types/src/application.ts#L186-L195, packages/mime-types/src/application.ts#L368-L370)
References: packages/…/application.ts• L1-10 packages/…/application.ts• L186-195 packages/…/application.ts• L368-370
Audio group
The audio group identifies sound formats and their common file suffixes. It lets a route ask for the broad audio family while still giving browser filters a list of known audio MIME types. (packages/mime-types/src/audio.ts#L1-L20, packages/mime-types/src/audio.ts#L30-L36, packages/mime-types/src/audio.ts#L90-L112)
References: packages/…/audio.ts• L1-20 packages/…/audio.ts• L30-36 packages/…/audio.ts• L90-112
Image group
The image group identifies image formats across common web, camera, vector, and design files. It includes both widely used types such as JPEG and PNG and less common registered types, which keeps broad image routes useful without requiring each subtype in route code. (packages/mime-types/src/image.ts#L1-L20, packages/mime-types/src/image.ts#L78-L85, packages/mime-types/src/image.ts#L138-L156, packages/mime-types/src/image.ts#L258-L260)
References: packages/…/image.ts• L1-20 packages/…/image.ts• L78-85 packages/…/image.ts• L138-156 packages/…/image.ts• L258-260
Text group
The text group covers plain text, markup, data tables, and source files. Its entries also record UTF-8 where the source data defines it, but UploadThing uses the MIME type and extension mapping as the main classification contract. (packages/mime-types/src/text.ts#L1-L25, packages/mime-types/src/text.ts#L36-L50, packages/mime-types/src/text.ts#L147-L165, packages/mime-types/src/text.ts#L199-L203)
References: packages/…/text.ts• L1-25 packages/…/text.ts• L36-50 packages/…/text.ts• L147-165 packages/…/text.ts• L199-203
Video group
The video group identifies common video containers and older or vendor-specific video formats. Broad video routes use this group to cover known subtypes, while exact route keys can name one MIME type when a route needs a narrow match. (packages/mime-types/src/video.ts#L1-L24, packages/mime-types/src/video.ts#L42-L56, packages/mime-types/src/video.ts#L102-L125)
References: packages/…/video.ts• L1-24 packages/…/video.ts• L42-56 packages/…/video.ts• L102-125
Miscellaneous group
The miscellaneous group holds types that do not fit the main media and text families. It includes fonts, 3D models, chemical files, message files, and other special formats. The group joins the root catalog for lookup, but it is not a broad UploadThing file alias by itself. (packages/mime-types/src/misc.ts#L1-L4, packages/mime-types/src/misc.ts#L5-L46, packages/mime-types/src/misc.ts#L49-L75, packages/mime-types/src/misc.ts#L77-L123)
References: packages/…/misc.ts• L1-4 packages/…/misc.ts• L5-46 packages/…/misc.ts• L49-75 packages/…/misc.ts• L77-123
Lookup exports
The root MIME package combines all groups into one catalog and exposes typed views for lookup. Separate group entry points support smaller client bundles when a consumer only needs the groups used to build a file picker.
Catalog exports
The root package exposes MimeType as the union of catalog keys and FileExtension as the union of known suffixes. It also exposes mimeTypes, which maps each MIME type to its source record and extensions. The root package combines application, audio, image, text, video, and miscellaneous data before it creates these exports. (packages/mime-types/src/index.ts#L16-L38)
The package publishes separate application, audio, image, text, and video entry points. These entry points allow shared UI code to load only the group data needed to expand a broad file type into browser accept values. (packages/mime-types/package.json#L15-L76, packages/mime-types/tsdown.config.ts#L3-L11)
References: packages/…/index.ts• L16-38 packages/…/package.json• L15-76 packages/…/tsdown.config.ts• L3-11
Path lookup
The lookup export turns a path or extension into a MIME type. It normalizes the input to lower case, uses the final suffix, and returns false when the input has no known suffix. This makes file-name lookup a fallback rather than a claim that every file name has a known content type. (packages/mime-types/src/index.ts#L40-L43, packages/mime-types/src/index.ts#L59-L78)
References: packages/…/index.ts• L40-43 packages/…/index.ts• L59-78
Extension maps
The getTypes export provides the extension-to-MIME view, while getExtensions provides the MIME-to-extension view. The maps are built on first use and then reused. When more than one MIME entry names an extension, the catalog uses its source preference to choose one result for extension lookup. (packages/mime-types/src/index.ts#L45-L57, packages/mime-types/src/index.ts#L80-L125)
References: packages/…/index.ts• L40-43 packages/…/index.ts• L45-57 packages/…/index.ts• L59-78 packages/…/index.ts• L80-125
File classification
UploadThing uses the catalog at two connected boundaries. Client components turn route keys into picker filters, and shared validation turns each incoming file into the route key that controls its limits and upload settings.
Route keys
Routes accept two kinds of file key: a broad UploadThing alias such as image, audio, video, text, pdf, or blob, and an exact MimeType from the catalog. pdf is the named alias for application/pdf; blob is the catch-all for a file that has no recognized type or does not match a more specific route key. (packages/shared/src/file-types.ts#L1-L10, packages/shared/src/types.ts#L223-L238, packages/shared/src/utils.ts#L32-L40, packages/shared/src/utils.ts#L119-L135)
References: packages/…/file-types.ts• L1-10 packages/…/types.ts• L223-238 packages/…/utils.ts• L32-40 packages/…/utils.ts• L119-135
Client accept rules
Shared component helpers convert route keys into browser accept values. A broad media key includes its wildcard and the known MIME types from its group because some browsers and operating systems do not handle the wildcard alone. An exact MIME key passes through unchanged, while pdf maps to application/pdf; blob produces no MIME filter. (packages/shared/src/component-utils.ts#L5-L15, packages/shared/src/component-utils.ts#L28-L49, packages/shared/src/component-utils.ts#L52-L55)
The browser-side filter is a first check for user experience. It matches exact MIME strings, broad type/* families, and file-name suffixes. The server still classifies and checks the submitted file, so a picker filter does not replace route validation. (packages/shared/src/dropzone-utils.ts#L26-L47, packages/shared/src/dropzone-utils.ts#L61-L65, packages/shared/src/dropzone-utils.ts#L95-L115)
References: packages/…/component-utils.ts• L5-15 packages/…/component-utils.ts• L28-55 packages/…/dropzone-utils.ts• L26-47 packages/…/dropzone-utils.ts• L61-65 packages/…/dropzone-utils.ts• L95-115
Upload validation
Server validation first trusts the file's declared MIME type when it exists. If it is empty, validation uses lookup on the file name. The resulting broad family or exact MIME key selects the route config, after which file size and file count rules are checked. (packages/shared/src/utils.ts#L94-L136, packages/uploadthing/src/_internal/route-config.ts#L54-L85)
The upload request follows the same classification before it creates upload metadata. This keeps the type used for validation aligned with the type used for size limits, access settings, and downstream upload records. (packages/uploadthing/src/_internal/handler.ts#L485-L558)
flowchart LR
A[File name and declared MIME type] --> B{Declared type present?}
B -- Yes --> C[Use declared MIME type]
B -- No --> D[Look up file extension]
C --> E[Match exact type or broad family]
D --> E
E --> F{Route key found?}
F -- Yes --> G[Apply route limits and upload settings]
F -- No --> H[Reject or use blob catch-all]
References: packages/…/utils.ts• L94-136 packages/…/route-config.ts• L54-85 packages/…/handler.ts• L485-558
Change checklist
When these files or sections are changed, remember to consider these:
- A new or changed MIME entry must keep its extension list aligned with the root
lookupmaps and with the published group entry point used by browser helpers. - A change to a broad group must keep route aliases, client accept values, and server family matching in agreement.
- A change to the
pdforblobaliases must be checked at both the browser filter boundary and the server validation boundary. - A change to extension precedence can change the MIME type selected when more than one catalog entry names the same suffix.
- A change to the package export map must preserve both the root lookup exports and the group entry points used by shared components.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A browser sends an empty MIME type and the file name has no catalog match | A route without blob cannot classify the file and rejects it as unknown | Use blob when a route must accept files with no recognized type |
| A declared MIME type does not match the route's exact key or broad family | Server validation rejects the file before upload metadata is created | Keep exact MIME route keys aligned with the catalog and use broad aliases for families |
| A suffix appears under more than one MIME entry | Extension lookup returns one preferred MIME type rather than all possible types | Treat extension lookup as a best-effort fallback and review source precedence when editing entries |
| A broad media route is expanded without its group data | The browser accept filter may omit known subtypes on systems with weak wildcard support | Keep the matching group entry point available to the shared component helper |
| A catalog extension is stored in a form that does not match normalized lookup input | Files with that suffix fall through to unknown type even though the catalog appears to list it | Keep extension values in the same normalized form expected by lookup |
Key files
| File | Why to read it |
|---|---|
| packages/…/index.ts | Defines the combined catalog, typed lookup exports, and extension precedence. |
| packages/…/application.ts | Shows the application MIME group and its document and data coverage. |
| packages/…/audio.ts | Shows the audio group used for broad audio picker filters. |
| packages/…/image.ts | Shows the image group used for broad image picker filters. |
| packages/…/text.ts | Shows the text group used for broad text picker filters. |
| packages/…/video.ts | Shows the video group used for broad video picker filters. |
| packages/…/misc.ts | Shows the less common font, model, chemical, and message types included in root lookup. |
| packages/…/types.ts | Defines the relationship between broad UploadThing aliases and exact MIME type keys. |
| packages/…/component-utils.ts | Connects route keys and MIME groups to browser accept values. |
| packages/…/utils.ts | Connects declared types and file-name lookup to route classification. |
| packages/…/dropzone-utils.ts | Defines the client-side MIME and extension matching contract. |
| packages/…/route-config.ts | Applies the classified type to route size and count checks. |
| packages/…/handler.ts | Shows where classification enters the upload request flow. |