Claude Code KaTeX
Adds LaTeX math rendering to the Claude Code VSCode extension using KaTeX.
Temporary workaround for anthropics/claude-code#16446 until native LaTeX rendering is added.
Renders $...$ (inline) and $$...$$ (display) math expressions in Claude's chat responses.
Install
From VS Code Marketplace
Search for "Claude Code KaTeX" in the Extensions tab, or:
code --install-extension nuriyev.claude-code-katex
From .vsix file
- Download the latest
.vsix from Releases
- In VSCode:
Ctrl+Shift+P → Extensions: Install from VSIX...
- Reload when prompted
Usage
The extension patches Claude Code automatically on startup. If you need manual control:
Ctrl+Shift+P → Claude Code KaTeX: Enable LaTeX Rendering
Ctrl+Shift+P → Claude Code KaTeX: Disable LaTeX Rendering
Ctrl+Shift+P → Claude Code KaTeX: Check Status
How it works
On activation, the extension appends KaTeX (core + auto-render + a MutationObserver) to Claude Code's webview files. A MutationObserver watches for new chat content and renders any LaTeX expressions it finds. Code blocks are ignored.
When Claude Code updates, the patch is automatically re-applied.
extension.js of Claude Code is never modified. Only the webview bundle (which runs in an isolated browser context) is patched, and originals are backed up.
Disabling / Uninstalling
To temporarily disable LaTeX rendering, use the command:
Ctrl+Shift+P → Claude Code KaTeX: Disable LaTeX Rendering → reload when prompted.
To re-enable, use Claude Code KaTeX: Enable LaTeX Rendering.
Uninstalling the extension from the Extensions panel automatically cleans up the patch.
Why not the Disable button in the Extensions panel? The patch lives in Claude Code's webview files on disk. Claude Code loads its webview before this extension activates, so if we removed the patch on deactivate, the webview would load unpatched files before we could re-apply. Keeping files patched on disk ensures it works reliably across restarts.
Notes
- After Claude Code updates, you may need to reload the window once for the re-patch to take effect.
- There may be a brief flash of raw LaTeX during streaming responses (200ms debounce).
- Code blocks are never affected.
$variable inside `code` or code fences is left alone.
- This is a temporary workaround until anthropics/claude-code#16446 is resolved. Once Claude Code ships native LaTeX support, this extension can be uninstalled.
License
MIT