contentMediaType : String



This keyword declares the media type of the string instance.

Value This keyword should be set to a valid media type as defined in RFC 2046, like the registered IANA media types
Kind Annotation
Applies To String
Dialect 2020-12
Changed In None
Introduced In Draft 7
Vocabulary Content
Official Tests draft2020-12/content.json
Default None
Annotation String The content media type set by this keyword
Affected By None
Also See

The contentMediaType keyword in JSON Schema specifies the MIME type of the contents of a string. It is used to annotate the type of media contained within a string. It should be noted that:

  • This keyword is purely an annotation and does not directly affect validation.
  • It describes the media type of the binary string after it has been decoded as specified in contentEncoding.
  • It is recommended to set contentEncoding if contentMediaType is declared.


Schema with 'contentMediaType' and 'contentEncoding' keyword Schema
  "$schema": "",
  "contentEncoding": "base64",
  "contentMediaType": "application/json"
Valid An instance with a properly stringified JSON document encoded in base64 is valid Instance
"eyAibmFtZSI6ICJKb2huIERvZSIgfQ=="    // --> { "name": "John Doe" }
Valid An encoded value that represents invalid JSON data is still valid Instance
"eyAibmFtZSI6IH0="    // --> { "name": }
Valid A non-string instance is ignored Instance
{ "keyword": "/contentEncoding", "instance": "", "value": "base64" }
{ "keyword": "/contentMediaType", "instance": "", "value": "application/json" }