Short answer
Spell checking for .tex files in VS Code comes from an extension, usually Code Spell Checker. LaTeX Workshop builds and previews your document, but it doesn’t do the spell check. Install both, set your language in a cspell.json file, and add project terms to the word list.
Install the extensions
- Install LaTeX Workshop to compile and preview your document. It needs a TeX distribution such as TeX Live or MacTeX, which you install separately.
- Install Code Spell Checker from Street Side Software. It underlines misspelled words in
.texfiles. - Open a
.texfile. Misspelled words should show a wavy underline.
If nothing is underlined, see the troubleshooting section near the end of this guide.
Set the language in cspell.json
Create a file named cspell.json in the project folder you open in VS Code:
{
"version": "0.2",
"language": "en-US"
}
For German, set "language": "de-DE". Code Spell Checker may need a German dictionary package; check the extension’s documentation if German words stay underlined. Keeping the file in the project root means it applies to every .tex file in the project.
Add LaTeX-specific words
Names, acronyms, and package names are often flagged. Add them to the words list:
{
"version": "0.2",
"language": "en-US",
"words": ["biblatex", "TikZ", "Overleaf"]
}
You can also hover over a flagged word and use the quick fix to add it to the workspace. The extension then writes the word into your configuration.
Commands and math
Code Spell Checker usually handles common LaTeX command names. Custom macros from \newcommand and environment names may still be flagged, so add them to words as you find them. Math content can also produce noise.
Optional: grammar checking with LTeX
LTeX adds grammar and spell checking, powered by LanguageTool. It’s useful for longer prose. It runs on Java, so you may need a Java runtime, and it can be slower than a spell-only extension.
If you use both extensions, a word may get two underlines. Turn off spell checking in one of them for .tex files to avoid the double marks.
Where the setup breaks
Two limits appear in the extensions’ issue trackers:
- VS Code for the web. A Code Spell Checker issue reports that the extension doesn’t run in VS Code for the web, such as vscode.dev. Use desktop VS Code for spell checking.
- Overleaf virtual workspaces. When you edit an Overleaf project through the Overleaf Workshop extension, the spell checker runs in a virtual workspace. There, the config must be JSON, JSONC, or YAML. A JavaScript config file, or one that depends on
node_modules, doesn’t load. Usecspell.json.
The same issue thread reports that Overleaf’s custom URI scheme must be enabled before the checker works. Run cspell.showActionsMenu from the command palette, choose the option to include the scheme, and restart VS Code if prompted.
Troubleshooting
- Nothing is underlined. Check that Code Spell Checker is enabled for the file, and that the file is saved with a
.texextension. - Find out why a file isn’t checked. Open the file and run
cSpell.openFileInfoViewfrom the command palette. It shows the language and settings the checker used for that file. - German words are flagged. Confirm the language in
cspell.jsonisde-DE, then try reloading the window.
Related guides
- LaTeX spell check overview for Overleaf, Mac and local editors
- How can I check spelling in LaTeX? covers Aspell and Hunspell from the command line.
- LaTeX spell check in Sublime Text, Atom and Texmaker covers the other editors.