Search...Search plugins and themes...
⌘K
Sign in
  • Get started
  • Download
  • Pricing
  • Enterprise
  • Account
  • Obsidian
  • Overview
  • Sync
  • Publish
  • Canvas
  • Mobile
  • Web Clipper
  • CLI
  • Learn
  • Help
  • Developers
  • Changelog
  • About
  • Roadmap
  • Blog
  • Resources
  • System status
  • License overview
  • Terms of service
  • Privacy policy
  • Security
  • Community
  • Plugins
  • Themes
  • Discord
  • Forum / 中文论坛
  • Merch store
  • Brand guidelines
Follow us
DiscordTwitterBlueskyThreadsMastodonYouTubeGitHub
© 2026 Obsidian

CodeBlock Language Detector

Lars BückerLars Bücker448 downloads

Automatically detects and adds language tags to code blocks without specified language for proper syntax highlighting.

Add to Obsidian
  • Overview
  • Scorecard
  • Updates8

An intelligent plugin for Obsidian that automatically detects the programming language of code blocks and applies appropriate syntax highlighting.

How It Works

The plugin automatically detects code blocks without language specification and adds the appropriate language tag:

Before

```
def fibonacci(n):
    if n <= 1:
        return n
    return fibonacci(n-1) + fibonacci(n-2)

print(fibonacci(10))
```

After

```python
def fibonacci(n):
    if n <= 1:
        return n
    return fibonacci(n-1) + fibonacci(n-2)

print(fibonacci(10))
```

The plugin uses two intelligent detection methods:

  1. Highlight.js Detection: Utilizes the proven Highlight.js library for precise language recognition
  2. Pattern Matching: Analyzes code keywords, syntax patterns, and typical language constructs

Installation

Via Community Plugin Store (Recommended)

  1. Open Obsidian Settings
  2. Go to "Community plugins"
  3. Disable "Safe mode"
  4. Click "Browse" and search for "CodeBlock Language Detector"
  5. Install and enable the plugin

Manual Installation

  1. Download the latest version from the Releases page
  2. Extract files to your vault folder: VaultFolder/.obsidian/plugins/obsidian-codeblock-language-detector/
  3. Reload Obsidian and enable the plugin in settings

Features

🚀 Automatic Language Detection

  • Two-Stage Detection: Combines Highlight.js and Pattern Matching for highest accuracy
  • 70+ Supported Languages: Python, JavaScript, TypeScript, Java, C++, Go, Rust, PHP, SQL and many more
  • Configurable Confidence Threshold: Minimum confidence threshold adjustable from 0-100%

⚙️ Flexible Trigger Options

  • On Open: Automatic detection when opening a note
  • On Edit: Detection during note editing
  • On Save: Detection when saving the file
  • Manual: Only on command via Command Palette

🎯 Intelligent Processing Scope

  • Current Note: Processes only the currently opened note
  • Entire Vault: Analyzes all notes in the vault

📊 Comprehensive History System

  • Complete Tracking: Stores all detections with timestamps and confidence values
  • Undo Functionality: Reverse individual or all changes
  • Statistics: Shows overall detection activity statistics
  • History Browser: Clear overview of all past actions

History Modal

🔧 Advanced Configuration

  • Method Prioritization: Determine the order of detection methods
  • Language Filtering: Select specific languages for Pattern Matching
  • Notifications: Optional success/status messages
  • Import/Export: Backup and restore settings

Settings

The plugin offers extensive configuration options through the settings tab:

Trigger Behavior

Trigger Settings

Determine when automatic language detection should be executed:

  • When opening a note: On opening a note
  • When editing a note: During editing
  • When saving a note: On saving
  • Manual only: Only manually via Command Palette

Processing Scope

Scope Settings

Choose the processing scope:

  • Current note only: Only the current note
  • Entire vault: All notes in the entire vault

Detection Settings

Detection Settings

Confidence Threshold (0-100%): Minimum confidence threshold for language detection. Higher values reduce false positives but may also prevent correct detections.

Detection Method Order: Determines the order in which detection methods are applied:

  • Highlight.js → Pattern Matching: First Highlight.js, then Pattern Matching
  • Pattern Matching → Highlight.js: First Pattern Matching, then Highlight.js

Detection Methods

Detection Methods

Enable Highlight.js detection: Uses the proven Highlight.js library for automatic language detection. Very precise for common programming languages.

Enable Pattern Matching detection: Uses keyword and pattern matching for language detection. Particularly effective for domain-specific languages.

History & Undo

History Settings

Enable history tracking: Enables tracking of all detection and application operations for undo functionality.

Maximum history entries: Maximum number of history entries to store (10-1000). Higher values require more memory.

Clear history: Removes all history entries irreversibly.

Notifications

Notification Settings

Show notifications: Display notifications when languages are detected and applied.

Pattern Matching Languages

Pattern Languages

Select specific languages for Pattern Matching. Highlight.js detection is not affected by this setting.

Quick Actions:

  • Select All: Enable all available pattern languages
  • Select None: Disable all pattern languages

Available Languages: Over 20 preconfigured language patterns for JavaScript, Python, Java, C++, TypeScript, Bash, SQL and more.

Usage

Automatic Detection

Once the plugin is activated, it automatically detects code blocks based on the configured trigger settings. No further action required!

Manual Commands

Via Command Palette (Ctrl/Cmd + P):

  • Detect language in current note: Detects languages in the current note
  • Detect language in entire vault: Analyzes all notes in the vault
  • Show detection history: Opens the History modal
  • Undo last detection: Undoes the last detection
  • Clear all detections: Removes all automatically added language tags

History Browser

The History modal shows a chronological list of all detection activities:

  • Timestamp: When the detection occurred
  • File: In which note the change was made
  • Detected Language: Which language was detected
  • Confidence: Confidence value of the detection (0-100%)
  • Method: Which detection method was used
  • Status: Whether the change was applied or undone

Supported Languages

The plugin supports over 70 programming languages through the combination of Highlight.js and Pattern Matching:

Web Technologies: JavaScript, TypeScript, HTML, CSS, SCSS, JSON, XML Backend Languages: Python, Java, C#, C++, C, Go, Rust, PHP, Ruby Databases: SQL, MongoDB, Redis DevOps: Bash/Shell, PowerShell, Dockerfile, YAML, TOML Functional Languages: Haskell, Scala, Clojure, F# Others: Markdown, LaTeX, R, MATLAB, Swift, Kotlin, and many more

Technical Details

Detection Algorithm

  1. Highlight.js Detection: Uses statistical analysis and machine learning
  2. Pattern Matching: Analyzes keywords, syntax patterns, operators, and comment styles
  3. Confidence Scoring: Each detection receives a confidence value from 0-100%
  4. Fallback Mechanism: If one method fails, the next one is tried

Performance

  • Minimal Overhead: Optimized for large vaults with hundreds of notes
  • Asynchronous Processing: Does not block the Obsidian user interface
  • Intelligent Caching: Avoids repeated analysis of unchanged code blocks

Development

This plugin is Open Source and available under the MIT License. Contributions are welcome!

Repository: GitHub Issues & Feature Requests: GitHub Issues

Local Development

git clone https://github.com/bueckerlars/obsidian-codeblock-language-detector.git
cd obsidian-codeblock-language-detector
npm install
npm run dev

Support

For issues or questions:

  1. Check the known issues
  2. Create a new issue with detailed description
  3. Use the Discussion forum for general questions

License

MIT License - see LICENSE file for details.

HealthExcellent
ReviewPassed
About
Detect and tag fenced code blocks with language identifiers to enable correct syntax highlighting. Use Highlight.js and pattern matching to recognize 70+ languages, run automatically or on demand, and keep an undoable history of detections.
CodeSyntaxAutomation
Details
Current version
0.2.8
Last updated
4 weeks ago
Created
10 months ago
Updates
8 releases
Downloads
448
Compatible with
Obsidian 0.15.0+
Platforms
Desktop, Mobile
License
MIT
Report bugRequest featureReport plugin
Author
Lars BückerLars Bückerbueckerlars
GitHubbueckerlars
  1. Community
  2. Plugins
  3. Code
  4. CodeBlock Language Detector

Related plugins

Templater

Create and use dynamic templates.

VSCode Editor

Edit Code Files like VSCode.

CodeScript Toolkit

Allows to do a lot of things with JavaScript/TypeScript scripts from inside the Obsidian itself

Shiki Highlighter

Highlight code blocks with Shiki.

BRAT

Easily install a beta version of a plugin for testing.

Homepage

Open a note, base, or workspace on startup, or set it for quick access later.

Lazy Loader

Load plugins with a delay on startup, so that you can get your app startup down into the sub-second loading time.

Mermaid Tools

Improved Mermaid.js experience: visual toolbar with common elements and more.

Readwise Official

Sync highlights from Readwise to your vault.

Update modified date

Automatically update a frontmatter modified date field when the file is modified.