ForHosting KIT · Developer Utilities

MIME Type to File Extension Lookup

Turn a MIME content type into the file extension people and software commonly expect.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

This lookup accepts values such as application/json, image/jpeg, or text/html; charset=utf-8, normalizes casing, removes MIME parameters, and returns both a preferred extension and every common alternative in its built-in table. It is useful when a response header, upload record, or data URI tells you the media type but does not provide a safe filename. The operation is deterministic, runs without network access, and reports unknown types instead of inventing an extension.

Convert a content type into a practical filename suffix

HTTP responses, email attachments, object stores, and data URLs often identify a payload with a MIME content type while leaving its filename blank or unreliable. This lookup gives your application a practical suffix for that payload. Send a value in the familiar type/subtype form, such as image/jpeg, and the result supplies a primary extension plus an ordered list of recognized alternatives. The primary value is the conventional default for creating a filename, while the full list helps when you need to compare an existing filename or display accepted forms. Extensions are returned without a leading dot so they can be joined, compared, or formatted according to your own naming rules. The service does not inspect file bytes and does not claim that a header proves a file is genuine. It simply performs the inverse of an extension-to-MIME mapping against a documented, built-in set of common web, document, archive, font, audio, image, and video formats. That narrow purpose keeps the answer predictable and suitable for automation.

Understand normalization, aliases, and multiple extensions

Real content-type values are rarely as tidy as examples in a registry. Servers may capitalize parts of a type or append parameters such as a character encoding. The lookup trims surrounding whitespace, converts the media type to lowercase, and ignores everything after the first semicolon. Therefore Text/HTML; charset=UTF-8 resolves exactly like text/html. It validates the normalized type/subtype syntax before consulting the table, which separates malformed input from a valid but unsupported MIME type. Some formats have several familiar suffixes. For image/jpeg, for example, the preferred result is jpg and the alternatives include jpeg and jpe. For text/html, html is preferred and htm remains available. The order is intentional and stable, so callers can safely use primary_extension without creating their own preference rules. Input aliases content_type and mime are accepted for integration convenience, although mime_type is the canonical field shown in generated clients. The returned mime_type is also normalized, making it useful as a canonical value in logs, metadata records, cache keys, or later processing steps.

Use the result safely in ingestion and download workflows

A common workflow receives a body and a Content-Type header, chooses an extension, and stores the body under a generated name. Use primary_extension for that last component, but keep content validation separate. MIME metadata can be missing, mistaken, or controlled by an uploader, and adding a plausible suffix does not make untrusted bytes safe. If your system executes, previews, or publicly serves the result, inspect the content and apply the relevant security policy first. The full extensions list is especially useful for validation: normalize the suffix from an existing filename and check whether it appears in the returned alternatives, rather than rejecting a legitimate jpeg file because your preferred suffix is jpg. Unknown registered or vendor-specific types produce an explicit invalid-input error because guessing from subtype text can create misleading or dangerous filenames. Since the table is bundled with the capability, identical input always yields identical output and no request is sent to an external registry. That behavior makes the lookup appropriate for repeatable build tools, edge handlers, import pipelines, and tests. API execution costs $0.002 per item, while the browser experience can run the same pure lookup directly.

Name a downloaded response

Choose a conventional suffix when an HTTP response includes Content-Type but no usable Content-Disposition filename.

Check upload metadata

Compare an uploaded filename suffix with all common extensions associated with the declared MIME type.

Export stored binary objects

Reconstruct readable filenames from object metadata that retains a MIME type but not the original name.

Does the returned extension include a dot?

No. Extensions are returned as values such as jpg or html, without a leading dot.

What happens to charset and other MIME parameters?

Parameters after the first semicolon are ignored, so text/html; charset=utf-8 is looked up as text/html.

Why can one MIME type return several extensions?

Some formats have multiple established filename suffixes. The result identifies one preferred extension and preserves the common alternatives in stable order.

Does this verify the contents of a file?

No. It maps declared MIME metadata only. Inspect untrusted file bytes separately before execution, preview, or public delivery.

What happens when the MIME type is not in the table?

The lookup returns an invalid-input error rather than guessing an extension from the subtype.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/dev/extension-from-mime

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/dev/extension-from-mime \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mime_type":"application/json; charset=utf-8"}'
{
  "mime_type": "application/json; charset=utf-8"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "dev.extension_from_mime",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →