Open Source

Monaco Editor: VS Code's Code Editor for the Web

Monaco Editor is the code editor that powers VS Code, available as a web component with syntax highlighting, IntelliSense, and multi-language support.

Keeping this site alive takes effort — your support means everything.
無程式碼也能輕鬆打造專業LINE官方帳號!一鍵導入模板,讓AI助你行銷加分! 無程式碼也能輕鬆打造專業LINE官方帳號!一鍵導入模板,讓AI助你行銷加分!
Monaco Editor: VS Code's Code Editor for the Web

The core of Visual Studio Code – the most popular code editor in the world – is not locked inside the desktop application. Microsoft has made the Monaco Editor (microsoft/monaco-editor on GitHub) available as a standalone web component, bringing the full power of VS Code’s editing capabilities to any web browser. This has made Monaco Editor the backbone of countless online development environments, documentation tools, and code-related web applications.

Developed and maintained by Microsoft, Monaco Editor is the same code editor that powers VS Code, extracted and packaged as a JavaScript library. It provides syntax highlighting for over 60 programming languages, comprehensive IntelliSense with autocomplete and parameter hints, code folding, bracket matching, multi-cursor editing, find and replace with regex support, diff editing for side-by-side comparison, and an extensive extension API.

The editor is written in TypeScript and designed for performance in the browser. It uses virtual rendering to handle large files efficiently, lazy-loads language services to minimize initial load time, and supports web workers for background processing. Despite its desktop-class feature set, Monaco Editor loads and runs within the constraints of a web browser environment.


Editor Architecture

Monaco Editor’s architecture separates core editing functionality from language services and UI:

The separation between core editing and language services allows Monaco Editor to provide responsive typing even during computationally intensive language operations, which run in separate web workers.


Feature Comparison

FeatureMonaco EditorCodeMirrorAce Editor
Languages supported60+100+100+
TypeScript IntelliSenseFullPluginPlugin
Diff editorBuilt-inAdd-onAdd-on
Multi-cursor editingYesYesYes
MinimapYesAdd-onNo
Command paletteYesNoNo
Snippet supportYesYesYes
Bundle sizeLargeMediumMedium

Integration Patterns

Monaco Editor is used in several distinct integration patterns across the web. The most common is the full-code-editor pattern, where Monaco provides a complete editing experience for source code in a web application. Online IDEs like GitHub Codespaces and StackBlitz use this pattern, with Monaco handling the core editing and additional UI components providing file management, terminal, and debugging.

The embedded-editor pattern uses Monaco in a more limited context, such as editing a single code block in a documentation website or a configuration editor in a web application. In this pattern, Monaco is configured with restricted features appropriate for the use case.

The diff-editor pattern leverages Monaco’s built-in diff editor to show changes between two versions of code. This is used in code review tools, version control web UIs, and comparison interfaces where users need to understand what changed in a file.

Regardless of the pattern, Monaco’s API provides fine-grained control over the editor’s behavior. Configuration options, custom language services, theme definitions, and keyboard shortcuts are all programmable through the JavaScript API.



FAQ

What is the Monaco Editor? Monaco Editor is the open-source code editor component that powers Visual Studio Code, made available as a standalone web component by Microsoft. It provides syntax highlighting, IntelliSense, multi-language support, code folding, diff editing, and hundreds of other editing features in any web browser through a JavaScript API.

What programming languages does Monaco Editor support? Monaco Editor has built-in support for over 60 programming languages including JavaScript, TypeScript, Python, HTML, CSS, C++, C#, Java, Go, Rust, PHP, Ruby, SQL, JSON, YAML, and Markdown. Each language has syntax highlighting, bracket matching, auto-indentation, and configurable language-specific features.

What is IntelliSense in Monaco Editor? IntelliSense is Monaco Editor’s code completion and assistance system, providing autocomplete suggestions, parameter hints, quick info tooltips, and signature help as you type. For TypeScript and JavaScript, IntelliSense provides full language service support including type checking, error diagnostics, and refactoring suggestions.

Can Monaco Editor be customized? Yes, Monaco Editor is highly customizable through its comprehensive API. Developers can customize themes (colors, fonts, styling), keybindings, language definitions, completion providers, hover providers, diagnostic markers, minimap settings, and hundreds of other configuration options. Custom themes can be defined as JSON and shared across applications.

How does Monaco Editor compare to CodeMirror or Ace? Monaco Editor offers the richest feature set of any browser-based code editor, closely matching the VS Code desktop experience. It is more resource-intensive than CodeMirror or Ace but provides superior IntelliSense, TypeScript support, and overall editing capabilities. The choice depends on whether the application needs VS Code-level features or a lighter editor.


Further Reading

TAG
CATEGORIES