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

Code Block

paddanpaddan15k downloads

Convert text into code blocks with automatic language detection.

Add to Obsidian
  • Overview
  • Scorecard
  • Updates6

This plugin converts selected text or pasted text into a code block with automatic programming language detection. Select the languages to consider in the plugin settings.

Detection runs locally using highlight.js (all languages it ships with) plus the third-party Cypher grammar. Distinctive syntax such as shebangs, JSON objects and arrays, graph patterns, and certain language declarations takes priority over automatic scoring. C is recognized from common C headers when no C++ markers are present; fragments valid in both languages cannot always be distinguished. HTML uses the xml language, and TOML shares the ini grammar.

Empty input, likely plain prose, low-scoring results, and unresolved ties produce an unlabelled code block. Disabled languages are never selected, including by the syntax rules. If a snippet still gets the wrong language, edit the language after the opening code fence or narrow the enabled languages in settings. Detection is heuristic: a short fragment may be valid in several languages.

Development

npm install
npm run dev    # watch build
npm run build  # typecheck + production build
npm run lint
npm test

The detection tests include a representative snippet for every supported language, with both the full language selection and that language alone, plus short snippets, prose, shebangs, aliases, and disabled-language cases. These are regression examples, not an accuracy benchmark for arbitrary code.

data.json is Obsidian's local settings file for the plugin and is git-ignored. It appears in the project root after you enable the plugin in a vault for the first time.

HealthGood
ReviewSatisfactory
About
Convert selected or pasted text into a fenced code block with automatic programming-language detection. Choose which languages to include for detection; detection uses highlight.js and can occasionally guess incorrectly.
CodeLanguagesAutomation
Details
Current version
1.1.0
Last updated
5 days ago
Created
4 years ago
Updates
6 releases
Downloads
15k
Compatible with
Obsidian 0.12.16+
Platforms
Desktop, Mobile
License
MIT
Report bugRequest featureReport plugin
Author
paddanpaddan
github.com/paddan/code-block-plugin
GitHubpaddan
  1. Community
  2. Plugins
  3. Code
  4. Code Block

Related plugins

Templater

Create and use dynamic templates.

Homepage

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

Linter

Format and style your notes. Linter can be used to format YAML tags, aliases, arrays, and metadata; footnotes; headings; spacing; math blocks; regular Markdown contents like list, italics, and bold styles; and more with the use of custom rule options.

BRAT

Easily install a beta version of a plugin for testing.

Advanced URI

Control everything with URI.

QuickAdd

Quickly add new notes or content to your vault.

Lazy Loader

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

Hot Reload

Automatically reload in-development plugins when their files are changed

Mermaid Tools

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

Update modified date

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