How do I configure VS Code to enable code completion on .json files (jsonschema support)?

Michael_Scharf picture Michael_Scharf · May 5, 2015 · Viewed 9.3k times · Source

In the Visual Stuido Code demo minute 28:57-29:20 and 30:20-31:10, some cool JSON code completion is shown.

Where and how do I add a schema for my JSON files to a project?

How does VS Code know which schema to use for a given .json file?

Answer

Martin Aeschlimann picture Martin Aeschlimann · May 6, 2015

The association of JSON schemas to files is done in the settings (File, Preferences, User Settings or Workspace Settings), under the property 'json.schemas'.

This is an example how the JSON schema for bower is associated to the bower schema.

"json.schemas": [
    {
        "fileMatch": [
            "/bower.json",
            "/.bower.json"
        ],
        "url": "http://json.schemastore.org/bower"
    },
    ...

You can also use schemas located in your workspace or define a schema right in the settings itself. Check https://code.visualstudio.com/docs/languages/json for examples.