Json Schema file extension

Is there any naming convention for a json schema file extension? XML has .xsd (XML Schema Definition), what should json schema files have, .jsd (JSON Schema Definition)?


Solution 1:

From Gary Court:

I personally use .schema.json, but there is no official file extension. The official mime type however is "application/schema+json".

Solution 2:

According to the last draft (v4), there is not a new extension proposed for files storing json-schemas. .json extension is used profusely within that document. .json is also the preferred extension in validators (PHP, Ruby, Python).

So I think that .json should be the preferred option in absence of an official/standard new extension.

Solution 3:

From https://json-schema.org/understanding-json-schema/basics.html#id3

Since JSON Schema is itself JSON, it’s not always easy to tell when something is JSON Schema or just an arbitrary chunk of JSON. The $schema keyword is used to declare that something is JSON Schema. It’s generally good practice to include it, though it is not required.

So you can use .json as the file extension for JSON schema but maybe with a $schema keyword (although optional) for better distinction.