Skip to content

MIME types explained: what text/html and application/json tell the browser

Blog / Published 

A MIME type, now also called a media type, is a label in the form type/subtype that says what kind of data follows. Browsers, servers and email clients use it to decide how to show or handle a response. It is the reason a page renders as a page and a JSON response is not shown as a wall of text, unless the server says so.

Type and subtype

The first part is the broad family: text, image, audio, video, application and a few others. The subtype narrows it down. text/html is an HTML document, text/plain is plain text, image/png is a PNG file, and application/json is JSON. The generic fallback for unknown binary data is application/octet-stream.

Where you see them

The main place is the Content-Type header in an HTTP response. A line such as Content-Type: application/json; charset=utf-8 tells the client the body is JSON in UTF-8, which is why the JSON formatter is the right tool for a response with that header. Email uses the same labels for attachments, and file uploads use them in the form field.

The extension is only a hint

A file ending in .json is almost always JSON, but the name can lie. A server that trusts only the extension will serve a renamed file with the wrong type. The MIME type comes from the content, the header, or a mapping table, and each can disagree. When something renders strangely, check the header before you blame the file.

Looking one up

The MIME type lookup maps a file extension to its type and back, and runs in your browser. Use it when you are writing a server config or setting an upload filter and need the exact string.

Common mistakes

Written by Ján Turský

Creator of TextArray — building free, privacy-first tools that run entirely in your browser.