monaco-editor is a free, open source browsers & extensions project written in JavaScript and released under MIT. It has 46,758 GitHub stars, 4,128 forks and 859 open issues, and was last pushed 4 days ago. On this registry it ranks #4 of 65 tracked projects in Browsers & Extensions, with 5 head-to-head comparisons available. It gained 10 stars over the last 3 tracked days.

What is monaco-editor?

Monaco Editor is the fully featured code editor from VS Code, packaged as an npm library so that developers can embed the same editing experience inside their own browser based applications.

What it is

Monaco Editor is the editor component extracted from VS Code and published as a standalone JavaScript and TypeScript library. The project lives in the JavaScript ecosystem and ships through npm as the package monaco-editor. Rather than an application that users open directly, it is a library that application authors import, configure, and attach to the DOM, and the editor it produces is the same editing engine that VS Code itself uses.

The concrete problem it solves is that building a code editor from scratch, with language aware highlighting, completion, and hover information, is a large amount of work that has nothing to do with the product being built. Monaco Editor replaces that effort with an importable dependency. Applications that need syntax highlighting, smart editing features, or a file style editing surface inside a web page can adopt the editor instead of writing one, and they configure it through the documented API rather than by reimplementing editor behaviour.

Key capabilities

  • Ships the VS Code editing experience as the npm package monaco-editor, installed with npm install monaco-editor.
  • Distributes an ESM build inside /esm, compatible with bundlers such as webpack.
  • Publishes monaco.d.ts, which specifies the API of the editor; this file is what is actually versioned, and everything else is considered private.
  • Organises content through models, where a model represents an opened file, holds its text content, determines its language, and tracks edit history.
  • Identifies each model by a URI, with file:/// usable as a base path and inmemory://model/1 assigned when a model is created without one.
  • Provides smart editor features through providers, including completion and hover information, which often map to language server protocol features.
  • Supports localization by loading the matching nls script file before the main editor script, for example to load the editor in German.

Who uses it and how

  • Product teams embedding a code editing surface into a web application, where the editor is attached to the DOM as a user facing view of a model.
  • Applications that treat their content as a virtual file system, choosing model URIs carefully because features such as TypeScript import resolution and JSON IntelliSense depend on the file URI.
  • Teams wiring completion and hover behaviour to language tooling, since providers are not the same as language server protocol features but often map to them.
  • Developers debugging integrations in the interactive playground, which supports trying different versions and producing minimal reproducible examples for bug reports.
  • Applications managing lifecycle explicitly, disposing editors and calling model.dispose() to unregister a model and free its URI for reuse.

Getting started

Install the editor from npm with npm install monaco-editor, then import the ESM build from /esm alongside the types in monaco.d.ts. An interactive playground is hosted at the project homepage for trying features and testing versions before integrating.

How it compares

The facts name no set of paid products that this project replaces, so there is no licence or cost comparison to draw. Among the tools the facts do name, Monaco Editor sits as the editor extracted from VS Code and shipped independently, closely related to but distinct from VS Code the application, and adjacent to language server protocol tooling through its completion and hover providers.

When to use it — and when not to

A self-hoster must operate a JavaScript build pipeline, since the useful path is the ESM build inside /esm consumed by a bundler such as webpack, and must accept that the API surface is defined by monaco.d.ts while everything else may break with any release. Anyone depending on the AMD build should plan migration, because AMD support is deprecated and will be removed in future versions. It is also not the right choice for someone who wants an editor application rather than an editor library, and the 859 open issues alongside the truncated documentation excerpt suggest integrations require reading the sources.

project readme (upstream, from github) — read inline

Monaco Editor

Versions Versions Feature Requests Bugs

The Monaco Editor is the fully featured code editor from VS Code. Check out the VS Code docs to see some of the supported features.

image

Try it out

Try out the editor and see various examples in our interactive playground.

The playground is the best way to learn about how to use the editor, which features is supports, to try out different versions and to create minimal reproducible examples for bug reports.

Installing

> npm install monaco-editor

You will get:

  • inside /esm: ESM version of the editor (compatible with e.g. webpack)
  • monaco.d.ts: this specifies the API of the editor (this is what is actually versioned, everything else is considered private and might break with any release).

:warning: The monaco editor also ships an AMD build for backwards-compatibility reasons, but the AMD support is deprecated and will be removed in future versions.

Localization

To load the editor in a specific language, make sure that the corresponding nls script file is loaded before the main monaco editor script. For example, to load the editor in German, include the following script tag:

<script src="path/to/monaco-editor/esm/nls.messages.de.js"></script>

Check the sources for available languages.

Concepts

Monaco editor is best known for being the text editor that powers VS Code. However, it's a bit more nuanced. Some basic understanding about the underlying concepts is needed to use Monaco editor effectively.

Models

Models are at the heart of Monaco editor. It's what you interact with when managing content. A model represents a file that has been opened. This could represent a file that exists on a file system, but it doesn't have to. For example, the model holds the text content, determines the language of the content, and tracks the edit history of the content.

URIs

Each model is identified by a URI. This is why it's not possible for two models to have the same URI. Ideally when you represent content in Monaco editor, you should think of a virtual file system that matches the files your users are editing. For example, you could use file:/// as a base path. If a model is created without a URI, its URI will be inmemory://model/1. The number increases as more models are created.

Editors

An editor is a user facing view of the model. This is what gets attached to the DOM and what your users see visually. Typical editor operations are displaying a model, managing the view state, or executing actions or commands.

Providers

Providers provide smart editor features. For example, this includes completion and hover information. It is not the same as, but often maps to language server protocol features.

Providers work on models. Some smart features depends on the file URI. For example, for TypeScript to resolve imports, or for JSON IntelliSense to determine which JSON schema to apply to which model. So it's important to choose proper model URIs.

Disposables

Many Monaco related objects often implement the .dispose() method. This method is intended to perform cleanups when a resource is no longer needed. For example, calling model.dispose() will unregister it, freeing up the URI for a new model. Editors should be disposed to free up resources and remove their model listeners.

Documentation

Issues

Create issues in this repository for anything related to the Monaco Editor. Please search for existing issues to avoid duplicates.

FAQ

What is the relationship between VS Code and the Monaco Editor?

The Monaco Editor is generated straight from VS Code's sources with some shims around services the code needs to make it run in a web browser outside of its home.

What is the relationship between VS Code's version and the Monaco Editor's version?

None. The Monaco Editor is a library and it reflects directly the source code.

I've written an extension for VS Code, will it work on the Monaco Editor in a browser?

No.

Note: If the extension is fully based on the LSP and if the language server is authored in JavaScript, then it would be possible.

Why all these web workers and why should I care?

Language services create web workers to compute heavy stuff outside of the UI thread. They cost hardly anything in terms of resource overhead and you shouldn't worry too much about them, as long as you get them to work (see above the cross-domain case).

I see the warning "Could not create web worker". What should I do?

HTML5 does not allow pages loaded on file:// to create web workers. Please load the editor with a web server on http:// or https:// schemes.

Is the editor supported in mobile browsers or mobile web app frameworks?

No.

Why doesn't the editor support TextMate grammars?

Contributing / Local Development

We are welcoming contributions from the community! Please see CONTRIBUTING for details how you can contribute effectively, how you can run the editor from sources and how you can debug and fix issues.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

License

Licensed under the MIT License.

Frequently asked questions

Is monaco-editor free to use?

monaco-editor is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does monaco-editor do?

A browser based code editor

What is monaco-editor written in?

monaco-editor is primarily written in JavaScript. Its source is publicly available at https://github.com/microsoft/monaco-editor, and it has 46,758 GitHub stars.