A Zed extension providing syntax highlighting and editor support for HuJSON (Human JSON). HuJSON is a superset of JSON defined by the JWCC (JSON With Commas and Comments) specification. It permits C-style line or block comments and trailing commas in objects or arrays. All valid JSON is valid HuJSON. It strictly rejects other syntax extensions like unquoted keys or single-quoted strings. Unlike default JSON parsers that flag comments and trailing commas as syntax errors, this extension provides a valid Abstract Syntax Tree (AST). This preserves editor features like code folding, document symbols, and auto-formatting without throwing false error squiggles.
- Syntax highlighting via a dedicated Tree-sitter grammar
- File type association (.hujson, .jwcc)
- Automatic comment toggling (Cmd+/) for line and block comments
- Bracket matching and auto-closing pairs
- Document outline support for object key navigation
HuJSON is awaiting publication to the Zed extension registry (zed-industries/extensions#5937). Until that merges, install it directly from this repository:
- Clone this repository:
git clone https://github.com/ggfevans/zed-hujson.git
- Open the command palette in Zed (Cmd+Shift+P) and run Extensions: Install Dev Extension.
- Select the cloned repository's root directory.
That's it — .hujson and .jwcc files will highlight immediately. See Local Testing for the reload workflow.
After zed-industries/extensions#5937 merges, install it the usual way: open the Extensions view in Zed (Cmd+Shift+X), search for HuJSON, and click install.
The underlying parser lives at ggfevans/tree-sitter-hujson. It forks tree-sitter-json to allow optional trailing commas via the commaSep helper.
The extension pins this grammar by repository URL and commit hash in extension.toml. To update the pinned revision, update the commit value and run the query check script.
To enable format-on-save with hujsonfmt, add the following to your Zed settings.json:
{
"languages": {
"HuJSON": {
"formatter": {
"external": {
"command": "hujsonfmt",
"arguments": []
}
},
"format_on_save": "on"
}
}
}Install hujsonfmt with:
go install github.com/tailscale/hujson/cmd/hujsonfmt@latestNote: Zed extensions cannot yet register a default external formatter (zed#31904). When that API lands, this extension will provide formatting out of the box with no manual config required.
This extension registers the hujson grammar ID. It isolates tracking to .hujson and .jwcc files. It does not conflict with or override Zed's built-in json or jsonc grammars.
This extension is particularly useful for formats like Tailscale ACL policy files, which rely on HuJSON features that standard JSON parsers flag as syntax errors.
Fenced code blocks tagged hujson are highlighted inside Markdown documents with no extra setup. Zed matches the fence's info string to this extension by language name, so the Markdown grammar injects HuJSON highlighting for you — no injections.scm or grammar change required:
```hujson
{
// comments and trailing commas are highlighted here
"name": "tailscale-acl",
"hosts": { "server": "100.64.0.1", },
}
```See examples/markdown-fence.md for a ready-to-open demo.
- Rust stable with the WebAssembly target (
rustup target add wasm32-wasip2) - Zed Preview (required for local extension loading)
git— the query check clones the pinned grammar
Grammar development (changing
grammar.js, regenerating the parser withtree-sitter-cli) happens in the separate ggfevans/tree-sitter-hujson repository. This repository consumes the pre-generated grammar, so notree-sitter-cliis needed here.
Compile the extension and verify the Tree-sitter queries against your pinned grammar:
cargo build --release --target wasm32-wasip2
./scripts/check-queries.sh
- Open the command palette in Zed (Cmd+Shift+P).
- Run Extensions: Install Dev Extension.
- Select this repository root directory.
- Open examples/sample.hujson to verify the syntax highlighting and comment behavior.
Use Extensions: Reload Extensions from the command palette to apply updates after making changes.
MIT
