Search code examples
mime-typesdata-uri

Correct MIME type for data URL


I have an image which is encoded as a Data URL (RFC 2397, formerly "data URI", commonly used in browsers), so it looks like "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQA...". It has its own media type and encoding specified internally, but is itself an ascii-compatible string. What's the right content type to use to describe data in this already-wrapped format?

I know I could unwrap it from the data-url format and use the underlying content-type (in this case image/jpeg), but for reasons out-of-scope of this question, that's complicated in my scenario. Plus, this format should have its own content type, right?


Solution

  • Since there might not be a correct answer to this question yet, and this SO question might itself define a reasonable answer for others asking this question, I'll document here my own proposal that I'm using:

    application/dataurl
    

    This is inspired by the accepted MIME-type for JSON, which is application/json. This seems appropriate to me as both are data formats which can wrap arbitrary content.