128

What are people using as the length of a MIMEType field in their databases? The longest one we've seen so far is 72 bytes:

application/vnd.openxmlformats-officedocument.wordprocessingml.document

but I'm just waiting for a longer one. We're using 250 now, but has anyone seen a longer MIMEType than that?

Edit: From the accepted answer, 127 for type and sub-type each, so that's 254 max, plus the '/' is a limit of 255 for the combined value.

Walden Leverich
  • 4,416
  • 2
  • 21
  • 30

1 Answers1

196

According to RFC 4288 "Media Type Specifications and Registration Procedures", type (eg. "application") and subtype (eg "vnd...") both can be max 127 characters. So including the slash, the maximum length is 255.

Edit: Meanwhile, that document has been obsoleted by RFC 6838, which does not alter the maximum size but adds a remark:

Also note that while this syntax allows names of up to 127 characters, implementation limits may make such long names problematic. For this reason, <type-name> and <subtype-name> SHOULD be limited to 64 characters.

roskakori
  • 3,139
  • 1
  • 30
  • 29
ax.
  • 58,560
  • 8
  • 81
  • 72
  • 1
    Damn, I'd searched for that and never could find a good reference. – Walden Leverich Mar 13 '09 at 20:04
  • 153
    For those who are not good at maths, that makes 127+1+127 = **255** if you include the slash. – Álvaro González Feb 10 '12 at 10:34
  • 2
    Has anyone an example of a mime type that goes over 127 chars? I doubt there are much? At least I've never seen one and I don't think they're good in any way. – floriank Mar 02 '16 at 08:57
  • 16
    Math is not for programmers. – AlienWebguy Apr 06 '18 at 16:06
  • 1
    @burzum, this one has 54 cars `application/x-nokia-9000-communicator-add-on-software`, the fact is not that a MIME type with 255 chars exists, it's only about the specification of the RFC 4288 that fixes the max length to 255 chars, so the question "how long" is answered in a universal way. – Karl.S Nov 21 '18 at 23:27
  • 1
    The MIME type for `.pptx` files is `application/vnd.openxmlformats-officedocument.presentationml.presentation` which has 73 characters. The subtype alone is 61 characters, which is very close to the limit mentioned in RFC 6838. – jlh Jan 08 '20 at 08:31
  • 5
    Today's longest entry in https://www.iana.org/assignments/media-types/media-types.xhtml is `application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml` (plus 2 more of the same length), which makes 11 + 1 + 72 (more than the suggested 64 subtype chars) = 84 chars. – ax. Feb 25 '21 at 21:56