115

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)?

jruizaranguren
  • 11,153
  • 7
  • 53
  • 70
Fresa
  • 1,261
  • 2
  • 9
  • 8
  • 3
    As someone working on the JSON Schema specification currently, it's not really something that's been considered. If you think it should be, feel free to open an issue on the github repo. – Relequestual Dec 22 '16 at 10:16

6 Answers6

124

From Gary Court:

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

chharvey
  • 7,457
  • 6
  • 53
  • 83
Eric Hartford
  • 14,576
  • 4
  • 32
  • 47
21

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.

jruizaranguren
  • 11,153
  • 7
  • 53
  • 70
4

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.

Saikat
  • 11,375
  • 15
  • 92
  • 108
2

I've started using .jschema after I had a run-in with an extension-based JSON Schema parser that automatically added id's to external RAML examples which are also .json files.

They are a specific format, after all. HTML is XML, which is UML, and we use a different file extension for each of those.

Michał Tatarynowicz
  • 1,254
  • 2
  • 14
  • 31
0

My suggestion is .jsd or .jsonsd standing for Json Schema Document.

I followed the way XML Schemas are named XSD (Xml Schema Document)

Fabrice T
  • 632
  • 8
  • 20
0

A JSON Schema is a valid JSON file so the extension .json is OK.

Then, the first attribute of your file should be '$schema' to declare the version of the specification you are using. Eg.

    {
      "$schema": "https://json-schema.org/draft/2019-09/schema",