A lightweight Java parser for cspell that spell checks the prose in your code: comments and strings. It has no dependencies, and it gives you control over what gets checked, from Javadoc comments to text blocks.
The quickest way to get started is to import the recommended settings, which registers the plugin and selects it for every supported file type:
cspell.config.jsonc
For more control - for example, to apply it alongside other settings - wire the plugin in yourself and choose the language IDs to use it for:
cspell.config.jsonc
{
"import": ["@cspell/parser-java-strings-comments"],
"languageSettings": [
{
"languageId": "java",
"parser": "java-strings-comments",
},
],
}The plugin provides these parsers. Where Recommended is yes, recommended enables the named parser for
files with that Language ID:
| Language ID | Parser Name | Recommended |
|---|---|---|
| java | java-strings-comments | yes |
By default, every comment and string is spell checked, and the rest of the code isn't. Use customizePlugin
to change what gets checked. For example, to check only Javadoc comments:
cspell.config.ts or cspell.config.mjs
import { customizePlugin } from '@cspell/parser-java-strings-comments/plugin';
// Check only Javadoc comments.
export default customizePlugin({ tags: { '*': false, 'comment.block.doc': true } }).defineConfig();NOTE:
Keys in
tagsare matched hierarchically against the tags below. For example, the keystringalso matches the more specificstring.textBlock, unless a more specific key overrides it. A key can also use*as a wildcard, such ascomment.*, or a bare*for everything not otherwise matched.
Calling customizePlugin gives you a customized copy of the plugin. Call defineConfig() on it to get a
complete cspell config, or keep adjusting it first. For example, to give the parser a different name:
customizePlugin().renameParser('java-strings-comments', 'my-java-parser');Each part of a file gets its most specific tag plus the more general ones above it. For example, a Javadoc
comment is tagged comment.block.doc, comment.block, and comment, so a filter can use whichever level it
needs.
| Tag | Meaning |
|---|---|
comment |
Any comment |
comment.line |
A // line comment |
comment.block |
A /* ... */ block comment |
comment.block.doc |
A /** ... */ Javadoc comment |
string |
Any string-like literal |
string.singleQuote |
A '...' character literal |
string.doubleQuote |
A "..." string literal |
string.textBlock |
A """...""" text block (Java 15+) |
code |
Everything else (off by default) |
By default, keywords, identifiers, and everything else tagged code aren't spell checked. To check them too:
cspell.config.ts or cspell.config.mjs
import { customizePlugin } from '@cspell/parser-java-strings-comments/plugin';
// Also check code, such as identifiers and keywords.
export default customizePlugin({ tags: { code: true } }).defineConfig();Use customizePlugin(options) to control which parts of a file get spell checked, based on the tags
the parser gives each part.
interface CustomizePluginOptions {
/** Chooses which tagged segments every parser keeps. */
tags: TagFilterOptions;
}Everything including code
const option = { tags: { '*': true } };Everything except code
const option = { tags: { '*': true, code: false } };Only comments
const option = { tags: { '*': false, comment: true } };Turn off Javadoc comments
const option = { tags: { 'comment.block.doc': false } };Use TagFilterOptions to set the filter criteria for the text sent to the spell checker.
The values are inherited hierarchically:
comment: falsealso impliescomment.lineisfalseunless overridden by'comment.line': true
Wildcards:
*wildcards are weak matches. A more specific match will win.
/**
* A tag name, or a `*`-wildcard pattern matching one.
*/
type TagPattern = string;
interface TagFilterOptions {
/**
* The default filter setting for any tag not otherwise matched.
* @default true
*/
'*'?: boolean | undefined;
/**
* Filter setting for the specific tag or wildcard pattern.
*
* If not specified, the default (`'*'`) will be used.
*/
[tag: TagPattern]: boolean | undefined;
}| Tool | Version |
|---|---|
| cspell | >=10.0.0 |
| Code Spell Checker | >=4.4.0 |
If our spell checkers and plugins save you time, please consider supporting their development.
Please show your support through one of the following sites:
Copyright (c) 2026 Street Side Software
Brought to you by Street Side Software




{ "import": ["@cspell/parser-java-strings-comments/recommended"], }