Enhanced syntax highlighting for Obsidian using Shiki and TextMate grammars, providing IDE-quality code rendering in your notes.
- IDE-Quality Highlighting: Uses the same TextMate grammars as VSCode for accurate, semantic syntax highlighting
- 100+ Languages: Support for all languages bundled with Shiki, with automatic lazy loading
- Popular Themes: Choose from One Dark Pro, Dracula, Nord, GitHub Dark/Light, and more
- Automatic Theme Sync: Seamlessly switches between light and dark themes as you toggle Obsidian's theme
- Copy Button: Quick copy-to-clipboard functionality on hover
- Line Numbers: Optional line numbering for code blocks
- Live Preview Support: Works in both Reading mode and Live Preview mode
- Lightweight: Lazy loading keeps memory footprint minimal
- Zero Configuration: Works out of the box with sensible defaults
Obsidian's default syntax highlighting uses CodeMirror 6 with Lezer parsers, which have limitations:
- Inaccurate tokenization (e.g., Go's
context.Contextrenders as one token instead ofpackage.Type) - Limited semantic understanding compared to IDE-grade parsers
- Theme inconsistency for users coming from VSCode or other IDEs
Shiki solves these problems by using the exact same TextMate grammars as VSCode, providing:
- 95%+ visual accuracy match with VSCode
- Accurate semantic coloring for complex language constructs
- Consistent experience across your editor and notes
- Open Obsidian Settings
- Go to Community Plugins and disable Safe Mode
- Click Browse and search for "Shiki Syntax Highlighter"
- Click Install, then Enable
- Download the latest release from GitHub Releases
- Extract the files to your vault's plugins folder:
<vault>/.obsidian/plugins/shiki-highlighter/ - Reload Obsidian
- Enable the plugin in Settings > Community Plugins
Once installed, the plugin automatically highlights all code blocks in your notes. No additional configuration needed!
package main
import "context"
func process(ctx context.Context) error {
// context.Context now renders with proper package/type distinction
return nil
}Access plugin settings through Settings > Shiki Syntax Highlighter:
| Setting | Description | Default |
|---|---|---|
| Light mode theme | Theme for light mode | github-light |
| Dark mode theme | Theme for dark mode | one-dark-pro |
| Lazy load languages | Load grammars on-demand | true |
| Show line numbers | Display line numbers | false |
| Show copy button | Show copy button on hover | true |
| Enable in Live Preview | Apply highlighting in Live Preview | true |
- One Dark Pro
- GitHub Dark
- GitHub Light
- Dracula
- Nord
- Monokai
- Min Light
- Min Dark
The plugin pre-loads these languages:
- Go
- TypeScript/JavaScript
- Python
- Rust
- Java
- YAML
- JSON
- Bash
- SQL
All other languages supported by Shiki (100+) are automatically loaded on demand.
- Startup: Zero impact on Obsidian startup time
- Highlighting: < 200ms for 500-line code blocks
- Memory: Minimal footprint with lazy loading
- Bundle Size: < 500KB
- Obsidian Version: 1.0.0 or later
- Mobile: Fully supported on iOS and Android
- Themes: Compatible with all Obsidian themes
- Other Plugins: No known conflicts
See CONTRIBUTING.md for development setup and guidelines.
git clone https://github.com/yaklabco/obsidian-shiki-highlighter.git
cd obsidian-shiki-highlighter
npm install
npm run devnpm test- Check that the plugin is enabled in Settings > Community Plugins
- Try toggling the plugin off and on
- Verify your code fence uses triple backticks with a supported language
- Disable "Enable in Live Preview" in plugin settings
- Highlighting will still work in Reading mode
- Try toggling Obsidian's theme (light/dark) twice
- Reload Obsidian
- Check that your theme selection in settings is valid
- Custom theme support
- Per-language theme overrides
- Inline code highlighting
- Export highlighted code as HTML
- Grammar customization UI
- Built with Shiki by Pine Wu and contributors
- Inspired by VSCode's syntax highlighting
- TextMate grammars from the open-source community
MIT License - see LICENSE for details
- Report bugs: GitHub Issues
- Feature requests: GitHub Discussions
- Documentation: GitHub Wiki
See CHANGELOG.md for release history.
Made with care by James Ainslie