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 valueThe anatomy of a MIME type
The grammar, in one line:
type "/" subtype ["+" suffix]
Concrete examples:
text/plain— typetext, subtypeplainapplication/json— typeapplication, subtypejsonapplication/ld+json— typeapplication, subtypeld, suffixjson
- The slash is required. It separates the type from the subtype.
- Both sides must be non-empty tokens. A token is letters, digits, and a small set of symbols.
- A suffix is optional. It follows a plus sign and describes the structured syntax of the
subtype (
+json,+xml,+zip). - Type and subtype are case-insensitive. The canonical form writes them lowercase.
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:
vnd.— vendor-defined types such asapplication/vnd.ms-excelandapplication/vnd.apple.mpegurlprs.— personal/unregistered typesx-— legacy unregistered convention, as inapplication/x-www-form-urlencoded
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
| Before | Canonical form |
|---|---|
Application/JSON | application/json |
Application/Vnd.Example+Json | application/vnd.example+json |
text/plain | unchanged, 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.