# microsoft/monaco-editor architecture

> Architecture diagram of the GitHub repository microsoft/monaco-editor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoft/monaco-editor
- Repository: https://github.com/microsoft/monaco-editor

## Overview

Monaco Editor is a browser-based code-editor library. The main user workflow is to create an editor for a text model, edit content, and receive language-aware assistance through providers and language workers. The repository also includes a playground and an optional LSP client. The README documents core concepts and capabilities; sampled source confirms entry-point wiring and worker creation, but not all editor internals or every language-service interaction.

Main entry points: [`src/index.ts`](https://github.com/microsoft/monaco-editor/blob/main/src/index.ts) (Public Entry), [`src/languages/features/register.all.ts`](https://github.com/microsoft/monaco-editor/blob/main/src/languages/features/register.all.ts) (Language Features), [`src/internal/common/workers.ts`](https://github.com/microsoft/monaco-editor/blob/main/src/internal/common/workers.ts) (Worker Factory), [`src/languages/register.all.ts`](https://github.com/microsoft/monaco-editor/blob/main/src/languages/register.all.ts) (Language Registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_editor["Editing Core"]
  node_entry["Public Entry<br/>[index.ts]"]
  node_editorapi["Editor API<br/>[editor.ts]"]
  node_model["Text Models<br/>[editor.ts]"]
  node_ui_features["Editor Features<br/>[register.all.ts]"]
end

subgraph group_language["Language Services"]
  node_language_defs["Language Definitions<br/>[register.all.ts]"]
  node_language_reg["Language Registration<br/>[register.all.ts]"]
  node_language_features["Language Features<br/>[register.all.ts]"]
  node_ts_worker_mgr["TypeScript Worker<br/>[workerManager.ts]"]
  node_json_worker_mgr["JSON Worker<br/>[workerManager.ts]"]
  node_html_worker_mgr["HTML Worker<br/>[workerManager.ts]"]
  node_css_worker_mgr["CSS Worker<br/>[workerManager.ts]"]
  node_worker_factory["Worker Factory<br/>[workers.ts]"]
end

subgraph group_lsp["LSP Integration"]
  node_lsp_client["LSP Client<br/>[LspClient.ts]"]
  node_lsp_sync["Document Sync"]
  node_lsp_connection["LSP Connection<br/>[LspConnection.ts]"]
end

subgraph group_playground["Playground"]
  node_playground["Interactive Playground<br/>[PlaygroundPage.tsx]"]
  node_playground_editor["Playground Editor<br/>[MonacoEditor.tsx]"]
end

node_user(("Editor User"))
node_language_server(("Language Server"))

node_user -->|"imports library"| node_entry
node_entry -->|"exports API"| node_editorapi
node_entry -->|"loads features"| node_ui_features
node_entry -->|"exports languages"| node_language_reg
node_language_reg -->|"registers definitions"| node_language_defs
node_language_reg -->|"registers services"| node_language_features
node_user -->|"creates editor"| node_editorapi
node_editorapi -->|"uses model"| node_model
node_model -->|"provides language context"| node_language_features
node_language_features -->|"uses worker manager"| node_ts_worker_mgr
node_language_features -->|"uses worker manager"| node_json_worker_mgr
node_language_features -->|"uses worker manager"| node_html_worker_mgr
node_language_features -->|"uses worker manager"| node_css_worker_mgr
node_ts_worker_mgr -->|"creates worker"| node_worker_factory
node_json_worker_mgr -->|"creates worker"| node_worker_factory
node_html_worker_mgr -->|"creates worker"| node_worker_factory
node_css_worker_mgr -->|"creates worker"| node_worker_factory
node_entry -.->|"exports optional client"| node_lsp_client
node_lsp_client -->|"synchronizes documents"| node_lsp_sync
node_lsp_client -->|"dispatches requests"| node_lsp_connection
node_lsp_connection -->|"sends protocol messages"| node_language_server
node_language_server -->|"returns responses"| node_lsp_connection
node_user -->|"tries examples"| node_playground
node_playground -->|"renders editor"| node_playground_editor
node_playground_editor -->|"loads library"| node_entry

click node_entry "https://github.com/microsoft/monaco-editor/blob/main/src/index.ts"
click node_editorapi "https://github.com/microsoft/monaco-editor/blob/main/src/editor.ts"
click node_model "https://github.com/microsoft/monaco-editor/blob/main/src/editor.ts"
click node_ui_features "https://github.com/microsoft/monaco-editor/blob/main/src/features/register.all.ts"
click node_language_defs "https://github.com/microsoft/monaco-editor/blob/main/src/languages/definitions/register.all.ts"
click node_language_reg "https://github.com/microsoft/monaco-editor/blob/main/src/languages/register.all.ts"
click node_language_features "https://github.com/microsoft/monaco-editor/blob/main/src/languages/features/register.all.ts"
click node_ts_worker_mgr "https://github.com/microsoft/monaco-editor/blob/main/src/languages/features/typescript/workerManager.ts"
click node_json_worker_mgr "https://github.com/microsoft/monaco-editor/blob/main/src/languages/features/json/workerManager.ts"
click node_html_worker_mgr "https://github.com/microsoft/monaco-editor/blob/main/src/languages/features/html/workerManager.ts"
click node_css_worker_mgr "https://github.com/microsoft/monaco-editor/blob/main/src/languages/features/css/workerManager.ts"
click node_worker_factory "https://github.com/microsoft/monaco-editor/blob/main/src/internal/common/workers.ts"
click node_lsp_client "https://github.com/microsoft/monaco-editor/blob/main/monaco-lsp-client/src/adapters/LspClient.ts"
click node_lsp_sync "https://github.com/microsoft/monaco-editor/blob/main/monaco-lsp-client/src/adapters/TextDocumentSynchronizer.ts"
click node_lsp_connection "https://github.com/microsoft/monaco-editor/blob/main/monaco-lsp-client/src/adapters/LspConnection.ts"
click node_playground "https://github.com/microsoft/monaco-editor/blob/main/website/src/website/pages/playground/PlaygroundPage.tsx"
click node_playground_editor "https://github.com/microsoft/monaco-editor/blob/main/website/src/website/components/monaco/MonacoEditor.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_editorapi,node_model,node_ui_features,node_user toneBlue
class node_language_defs,node_language_reg,node_language_features,node_ts_worker_mgr,node_json_worker_mgr,node_html_worker_mgr,node_css_worker_mgr,node_worker_factory toneAmber
class node_lsp_client,node_lsp_sync,node_lsp_connection,node_language_server toneMint
class node_playground,node_playground_editor toneRose
```

## Components

### Editing Core

- [Public Entry](https://github.com/microsoft/monaco-editor/blob/main/src/index.ts): `src/index.ts`
- [Editor API](https://github.com/microsoft/monaco-editor/blob/main/src/editor.ts): `src/editor.ts`
- [Text Models](https://github.com/microsoft/monaco-editor/blob/main/src/editor.ts): `src/editor.ts`
- [Editor Features](https://github.com/microsoft/monaco-editor/blob/main/src/features/register.all.ts): `src/features/register.all.ts`

### Language Services

- [Language Definitions](https://github.com/microsoft/monaco-editor/blob/main/src/languages/definitions/register.all.ts): `src/languages/definitions/register.all.ts`
- [Language Registration](https://github.com/microsoft/monaco-editor/blob/main/src/languages/register.all.ts): `src/languages/register.all.ts`
- [Language Features](https://github.com/microsoft/monaco-editor/blob/main/src/languages/features/register.all.ts): `src/languages/features/register.all.ts`
- [TypeScript Worker](https://github.com/microsoft/monaco-editor/blob/main/src/languages/features/typescript/workerManager.ts): `src/languages/features/typescript/workerManager.ts`
- [JSON Worker](https://github.com/microsoft/monaco-editor/blob/main/src/languages/features/json/workerManager.ts): `src/languages/features/json/workerManager.ts`
- [HTML Worker](https://github.com/microsoft/monaco-editor/blob/main/src/languages/features/html/workerManager.ts): `src/languages/features/html/workerManager.ts`
- [CSS Worker](https://github.com/microsoft/monaco-editor/blob/main/src/languages/features/css/workerManager.ts): `src/languages/features/css/workerManager.ts`
- [Worker Factory](https://github.com/microsoft/monaco-editor/blob/main/src/internal/common/workers.ts): `src/internal/common/workers.ts`

### LSP Integration

- [LSP Client](https://github.com/microsoft/monaco-editor/blob/main/monaco-lsp-client/src/adapters/LspClient.ts): `monaco-lsp-client/src/adapters/LspClient.ts`
- [Document Sync](https://github.com/microsoft/monaco-editor/blob/main/monaco-lsp-client/src/adapters/TextDocumentSynchronizer.ts): `monaco-lsp-client/src/adapters/TextDocumentSynchronizer.ts`
- [LSP Connection](https://github.com/microsoft/monaco-editor/blob/main/monaco-lsp-client/src/adapters/LspConnection.ts): `monaco-lsp-client/src/adapters/LspConnection.ts`

### Playground

- [Interactive Playground](https://github.com/microsoft/monaco-editor/blob/main/website/src/website/pages/playground/PlaygroundPage.tsx): `website/src/website/pages/playground/PlaygroundPage.tsx`
- [Playground Editor](https://github.com/microsoft/monaco-editor/blob/main/website/src/website/components/monaco/MonacoEditor.tsx): `website/src/website/components/monaco/MonacoEditor.tsx`

### Other components

- **Editor User**
- **Language Server**

## Connections

- Editor User → Public Entry: imports library
- Public Entry → Editor API: exports API
- Public Entry → Editor Features: loads features
- Public Entry → Language Registration: exports languages
- Language Registration → Language Definitions: registers definitions
- Language Registration → Language Features: registers services
- Editor User → Editor API: creates editor
- Editor API → Text Models: uses model
- Text Models → Language Features: provides language context
- Language Features → TypeScript Worker: uses worker manager
- Language Features → JSON Worker: uses worker manager
- Language Features → HTML Worker: uses worker manager
- Language Features → CSS Worker: uses worker manager
- TypeScript Worker → Worker Factory: creates worker
- JSON Worker → Worker Factory: creates worker
- HTML Worker → Worker Factory: creates worker
- CSS Worker → Worker Factory: creates worker
- Public Entry → LSP Client: exports optional client
- LSP Client → Document Sync: synchronizes documents
- LSP Client → LSP Connection: dispatches requests
- LSP Connection → Language Server: sends protocol messages
- Language Server → LSP Connection: returns responses
- Editor User → Interactive Playground: tries examples
- Interactive Playground → Playground Editor: renders editor
- Playground Editor → Public Entry: loads library
