1---
2title: JSON
3description: "Configure JSON language support in Zed, including language servers, formatting, and debugging."
4---
5
6# JSON
7
8JSON support is available natively in Zed.
9
10- Tree-sitter: [tree-sitter/tree-sitter-json](https://github.com/tree-sitter/tree-sitter-json)
11- Language Server: [zed-industries/json-language-server](https://github.com/zed-industries/json-language-server)
12
13## JSONC
14
15Zed also supports a super-set of JSON called JSONC, which allows single line comments (`//`) in JSON files.
16While editing these files you can use `cmd-/` (macOS) or `ctrl-/` (Linux) to toggle comments on the current line or selection.
17
18## JSONC Prettier Formatting
19
20If you use files with the `*.jsonc` extension when using `Format Document` or have `format_on_save` enabled, Zed invokes Prettier as the formatter. Prettier has an [outstanding issue](https://github.com/prettier/prettier/issues/15956) where it will add trailing commas to files with a `jsonc` extension. JSONC files which have a `.json` extension are unaffected.
21
22To workaround this behavior you can add the following to your `.prettierrc` configuration file:
23
24```json
25{
26 "overrides": [
27 {
28 "files": ["*.jsonc"],
29 "options": {
30 "parser": "json",
31 "trailingComma": "none"
32 }
33 }
34 ]
35}
36```
37
38## JSON Language Server
39
40Zed automatically out of the box supports JSON Schema validation of `package.json` and `tsconfig.json` files, but `json-language-server` can use JSON Schema definitions in project files, from the [JSON Schema Store](https://www.schemastore.org) or other publicly available URLs for JSON validation.
41
42### Inline Schema Specification
43
44To specify a schema inline with your JSON files, add a `$schema` top level key linking to your json schema file.
45
46For example to for a `.luarc.json` for use with [lua-language-server](https://github.com/LuaLS/lua-language-server/):
47
48```json
49{
50 "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
51 "runtime.version": "Lua 5.4"
52}
53```
54
55### Schema Specification via Settings
56
57> **Preview:** This feature is available in Zed Preview. It will be included in the next Stable release.
58
59You can associate JSON Schemas with file paths using relative paths in your language server settings. Zed resolves paths relative to your project root:
60
61```json [settings]
62"lsp": {
63 "json-language-server": {
64 "settings": {
65 "json": {
66 "schemas": [
67 {
68 "fileMatch": ["config/*.json"],
69 "url": "./schemas/custom-schema.json"
70 },
71 {
72 "fileMatch": ["*.config.json"],
73 "url": "~/global-schemas/shared.json"
74 },
75 {
76 "fileMatch": ["*/*.luarc.json"],
77 "url": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json"
78 }
79 ]
80 }
81 }
82 }
83}
84```
85
86Paths starting with `./` resolve relative to the worktree root. Paths starting with `~/` expand to your home directory.
87
88You can also pass any of the [supported settings](https://github.com/Microsoft/vscode/blob/main/extensions/json-language-features/server/README.md#settings) to json-language-server by specifying them in your Zed settings.json:
89
90<!--
91TBD: Add formatter (prettier) settings (autoformat, tab_size, etc)
92-->