Use the command line when you need to identify a local file from its content; use an online MIME type lookup when you need the registered base media type for an extension, format family, or MIME string. These are complementary workflows: one examines evidence in a file, while the other resolves a reference value for a response header, allowlist, test fixture, or configuration.

A filename ending in .json can suggest application/json, but it cannot prove that the bytes are JSON. Conversely, a command-line detector can inspect a file and report its apparent format, yet it does not automatically decide the correct Content-Type for an HTTP response. Keeping those responsibilities separate prevents a plausible label from becoming a broken response or an unsafe upload decision.

mime type lookup command line vs online
MIME Type Lookup: Command Line vs Online

Command-line and browser lookups answer different questions

Method What it uses Best fit Main limitation
Command-line content detection File bytes and a platform-specific recognition database Checking an unknown, extensionless, or mislabeled local file Detection can be heuristic and does not define your HTTP contract
Command-line extension mapping A filename and the locally installed mapping database Quick scripts, server configuration, and bulk lookups The extension is only a hint, and local mappings can differ
Browser-based MIME type lookup A curated table of 24 registered media types Finding and copying an exact base type from a known extension, family, or MIME string It does not inspect file content or cover every registered subtype

Choose the method based on the question you need answered. “What format are these bytes?” points toward command-line inspection or a format-specific validator. “Which base media type should this extension use in a response?” points toward a reference lookup. A third question—“Is this upload safe to accept?”—requires dedicated security controls and cannot be answered by either lookup alone.

For a browser-based reference, MIME Type Lookup searches 24 common web, document, image, audio, video, archive, font, and binary mappings entirely in your browser. Registered names are based on the IANA Media Types Registry, while practical filename associations are cross-checked against MDN’s common media types table.

Look up and copy a base media type

  1. Enter the identifier you have. Search with a filename extension such as .json, a format family such as image, a full MIME string such as font/woff2, or a plain-English format description.
  2. Review the matching record. Confirm that the description identifies the format you mean and check the listed extension aliases. A shared extension or similar label should not be accepted without checking the result.
  3. Copy the exact base media type. Clicking the copy control copies only the displayed type, such as application/json or image/png, so it can be pasted into a Content-Type header, allowlist, fixture, or configuration file.
  4. Validate the real content. Confirm that the bytes match the selected format using an appropriate detector, signature check, or safe format parser. The lookup itself performs no file inspection.
  5. Apply and test the value. Use the base type in the intended context, then test the actual response or upload path. Check the header emitted by the deployed application rather than relying only on framework configuration.

The lookup page runs locally in the browser. Search text is filtered in memory, copying occurs through the browser clipboard after a click, and no file is opened or uploaded. The result is a reference value, not a detection result.

The set is deliberately bounded to 24 frequently used media types rather than mirroring the entire IANA registry. Vendor-specific office formats, obscure registered subtypes, multipart boundary construction, email transfer encodings, and codec parameters are outside its scope. If the required format is absent, or standards compliance depends on the newest registration, consult the linked IANA registry.

Inspect content and headers from the command line

On systems with GNU-style libmagic support, run file --mime-type path/to/file to inspect a local file and print a detected media type. This is useful when a file has no extension, carries the wrong extension, or needs to be compared with the type expected by a server. The recognition database can be incomplete, and a result remains a detection rather than proof that the file passes application-specific validation.

A filename-based command answers a different question. For example, python3 -c "import mimetypes; print(mimetypes.guess_type('example.json')[0])" consults the local extension mapping rather than examining the file. It may print None when no mapping is available, and installed databases can differ between systems. Use this approach when a quick filename-derived value is useful, but confirm the expected registered value and validate the actual bytes before relying on it.

To inspect the type returned by a deployed HTTP service, request the response and examine its headers. The command curl -sS -D - -o /dev/null https://your-host.example/file displays response headers while discarding the response body. Look for the Content-Type actually returned on that request. This catches cases where an application setting, proxy, storage service, or content-negotiation path differs from the value in source configuration.

Command availability and option support vary by operating system, so check the local command documentation before relying on a particular flag. More importantly, neither a successful command nor a successful lookup proves that a file is safe to upload. Detection and security validation answer different questions.

Use a two-stage verification workflow

A reliable workflow combines a reference lookup, content inspection, and a deployed-response check.

  1. Establish the expected format. If you have only an extension or format description, use the browser lookup to locate the exact base media type and review its aliases.
  2. Inspect the content. Run an appropriate command-line detector or use a format-specific validator. Compare the reported format with the expected type, and investigate any mismatch instead of silently accepting the extension.
  3. Resolve discrepancies deliberately. A file named picture.png can contain non-PNG bytes. If the bytes and name disagree, determine which is authoritative for the workflow and handle the file as untrusted input until the format is established.
  4. Configure the exact base type. Paste the registered base value into the response header or relevant allowlist. Add a parameter only when the format and protocol contract require it.
  5. Test the real path. Retrieve the deployed resource, verify the returned Content-Type, and exercise the upload or download flow that consumes the file. Repeat the check when a proxy or generator can alter the response.

This sequence is more dependable than relying on a filename alone or treating a detected type as permission to accept arbitrary content. It also separates the lookup step from the later decisions about validation, authorization, and storage.

Separate types, parameters, and security controls

A media type normally contains a top-level type and subtype separated by a slash, such as image/png or application/json. Real HTTP headers may add parameters, but MIME Type Lookup intentionally returns only the base registered type. Charset declarations, multipart boundaries, codec parameters, Content-Disposition, compression, transfer encoding, and content negotiation are separate concerns. Appending charset=utf-8 is not a harmless universal default because the parameter must be appropriate for the format and contract.

Some formats also have contextual or historical alternatives. Current web guidance uses text/javascript for JavaScript, although older application and x-prefixed values remain compatibility artifacts. XML may use application/xml, while specialized XML formats have dedicated +xml subtypes. A gzip file may be associated with application/gzip or a platform’s nonstandard x-gzip label. These examples explain why a protocol contract and the latest registry entry should take priority over a casual extension convention.

Correct Content-Type helps browsers interpret responses and allows protections such as nosniff to work as intended. A wrong type can block modules, stylesheets, fonts, media, or downloads, and it can create unsafe content-sniffing behavior. For generated or proxied content, preserve an upstream type only when that upstream is controlled and verified. Check the type on the actual deployed response.

Extensions and browser-supplied File.type values are hints: a browser can return an empty, stale, or operating-system-derived value. The application/octet-stream entry is a generic fallback for unknown binary data and has no invented extension; it does not make the content safe. Secure upload handling still requires content inspection, size and format limits, safe decoding with a maintained parser, renamed stored objects, isolation from execution, and authorization. Never make the lookup result or request header the only security decision.

Related reading: Public NTP Servers API Alternative: Static Lookup.