Last active
August 24, 2026 15:35
-
-
Save aolin480/2cff3429b4692e46650428ccc7afef9a to your computer and use it in GitHub Desktop.
JSONC.sublime-syntax — Sublime Text 4 JSONC/JSON with Comments syntax. Install: Preferences → Browse Packages (or ~/Library/Application Support/Sublime Text/Packages on macOS, ~/.config/sublime-text/Packages on Linux), create Packages/JSONC/, save this file as JSONC.sublime-syntax, restart Sublime, then select JSONC in the bottom-right syntax menu.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # JSONC for Sublime Text 4 | |
| # | |
| # Install | |
| # 1. Open your Sublime Text Packages directory: | |
| # - macOS: ~/Library/Application Support/Sublime Text/Packages | |
| # - Linux: ~/.config/sublime-text/Packages | |
| # - Windows: %APPDATA%\Sublime Text\Packages | |
| # Or open the Command Palette (macOS: Cmd+Shift+P, Windows/Linux: Ctrl+Shift+P), | |
| # run "Preferences: Browse Packages", and use the folder that opens. | |
| # 2. Create a new directory named JSONC inside that Packages directory | |
| # (not inside the User subdirectory). | |
| # 3. Save this file there as: | |
| # Packages/JSONC/JSONC.sublime-syntax | |
| # 4. Restart Sublime Text. | |
| # 5. Open a .jsonc file, click the syntax name in the bottom-right corner, | |
| # and choose "JSONC". Optionally use | |
| # View → Syntax → Open all with current extension as… → JSONC | |
| # so .jsonc files open with this syntax automatically. | |
| # | |
| # Notes | |
| # - This syntax reuses Sublime's built-in JSON grammar and adds // and /* */ comments. | |
| # - Syntax highlighting does not stop plugins that run strict JSON validation on save. | |
| # If a validator popup still appears, disable that package's validate-on-save for .jsonc. | |
| %YAML 1.2 | |
| --- | |
| name: JSONC | |
| scope: source.json.jsonc | |
| version: 2 | |
| file_extensions: | |
| - jsonc | |
| contexts: | |
| prototype: | |
| - include: comments | |
| main: | |
| - include: scope:source.json | |
| comments: | |
| - match: // | |
| scope: punctuation.definition.comment.jsonc | |
| push: line-comment | |
| - match: /\* | |
| scope: punctuation.definition.comment.begin.jsonc | |
| push: block-comment | |
| line-comment: | |
| - meta_include_prototype: false | |
| - meta_scope: comment.line.double-slash.jsonc | |
| - match: $ | |
| pop: true | |
| block-comment: | |
| - meta_include_prototype: false | |
| - meta_scope: comment.block.jsonc | |
| - match: \*/ | |
| scope: punctuation.definition.comment.end.jsonc | |
| pop: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment