Content-Type troubleshooting

Invalid MIME type

A MIME type is type/subtype, with an optional structured suffix such as application/vnd.example+json. An "invalid MIME type" error almost always means one of a small set of structural problems: a missing slash, an empty type or subtype, a broken suffix, or illegal characters.

Check the value before changing code

Paste the failing value into CorrectMIME to see which part of the media type the parser rejects. The validator checks the string; it does not fetch a URL or inspect a file.

Validate a Content-Type value

The anatomy of a MIME type

The grammar, in one line:

type "/" subtype ["+" suffix]

Concrete examples:

Common invalid-type failures

Each example shows the broken form and the corrected form.

Missing slash

Broken: applicationjson

Without the slash there is no boundary between type and subtype, and the value cannot be a media type. An operator with a slash is usually the fix; the two words are rarely meant as one token.

Fixed: application/json

Empty type

Broken: /json

The type before the slash is empty. This happens when a value is assembled from fragments or a variable on the wrong side of the slash.

Fixed: application/json

Empty subtype

Broken: application/

A subtype must follow the slash. A trailing slash usually marks a truncated value or a template placeholder left empty.

Fixed: application/json

Broken structured suffix

Broken: application/json+

The plus sign starts a suffix, so the suffix itself must not be empty. Check that the value after + names the structured syntax (json, xml).

Fixed: application/ld+json

Illegal characters

Broken: text/*

The asterisk is a valid token in media ranges such as Accept: text/*, but the slash-star and */* forms belong to Accept headers, where clients declare what they accept. A Content-Type value must name a concrete subtype, and the asterisk is reported as an illegal character here.

Fixed: text/html

Tree prefixes and registered names

Subtype names can carry a tree prefix that signals who defined the type:

The validator checks the token shape of the whole subtype, including the prefix. Whether the name is actually registered is a separate question; CorrectMIME checks syntax and does not look up the IANA registry.

Canonical forms

BeforeCanonical form
Application/JSONapplication/json
Application/Vnd.Example+Jsonapplication/vnd.example+json
text/plainunchanged, already canonical

Casing of the type, subtype, and suffix is normalized to lowercase. This is the safe canonical rewrite; the media type name itself is preserved.

Working with other structured formats?

Validate and repair calendar files with CorrectICS, contact files with CorrectVCF, RSS/Atom/OPML feeds with CorrectFeed, or browse all CorrectFormats tools.