@codemirror/lang-xml

XML language support package for the CodeMirror 6 code editor

Library
npm
v6.1.0
10 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
23 /100 Needs Attention
Development Activity 8
Maintenance 0
Community 12
Maturity 60
Momentum 12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
74 /100 Good
Architecture 78
Code Quality 74
Innovation 60
Learning Curve 85

@codemirror/lang-xml plugs XML support into the CodeMirror 6 editor: it wires the Lezer XML grammar into CodeMirror’s language framework to provide syntax highlighting and indentation, and layers on editor-specific conveniences like automatic tag closing and schema-aware autocompletion for elements and attributes.

Calling xml() returns a LanguageSupport extension that can be dropped straight into a CodeMirror EditorView’s extensions array. Developers who want intelligent completions (suggesting valid child elements or attribute values as the user types) can optionally pass an ElementSpec/AttrSpec schema describing their XML dialect, which the bundled completeFromSchema helper turns into a CompletionSource.

What You Get

  • The xml() function returning a LanguageSupport extension ready to drop into a CodeMirror EditorView
  • xmlLanguage, a language provider based on the Lezer XML parser with highlighting and indentation baked in
  • autoCloseTags, an extension that inserts closing tags automatically when > or / is typed
  • completeFromSchema(elements, attributes) to build schema-aware completions for elements and attribute values
  • ElementSpec/AttrSpec types for describing an XML dialect’s allowed elements, children, and attributes

Common Use Cases

  • Adding XML editing support (highlighting, indentation, auto-close tags) to a CodeMirror-based web code editor
  • Building a schema-aware XML editor that autocompletes valid child elements and attribute values for a known dialect
  • Embedding an XML/XHTML/config-file editing experience inside a documentation or admin tool built on CodeMirror 6
  • Providing structured editing for XML-based formats (SVG, RSS, custom config schemas) in a browser-based tool

Under The Hood

Architecture - The package is small and cleanly split in two: src/xml.ts (113 lines) defines the xml() entry point, wiring the Lezer-XML-based xmlLanguage together with the autoCloseTags view extension and, when a schema is supplied, a completion source; src/complete.ts (241 lines) implements completeFromSchema, which walks the current syntax tree position to determine valid completions (element names, attribute names, attribute values) based on the caller-supplied ElementSpec/AttrSpec schema. All actual XML parsing is delegated to the separate @lezer/xml grammar package, keeping this package focused purely on editor integration (highlighting, indentation, completion) rather than parsing. Tech Stack - TypeScript, built with the shared @codemirror/buildhelper tooling used across all official CodeMirror 6 language packages. Runtime dependencies are the core CodeMirror 6 modules (@codemirror/autocomplete, @codemirror/language, @codemirror/state, @codemirror/view) plus @lezer/common and @lezer/xml, reflecting its role as a thin adapter layer over the shared CodeMirror/Lezer ecosystem rather than a standalone implementation. Code Quality - test/test-complete.ts specifically exercises the schema-driven completion logic, the most algorithmically interesting part of the package; the parsing and highlighting behavior is implicitly covered by the shared Lezer XML grammar’s own tests. The package has a single primary contributor (Marijn Haverbeke, the CodeMirror/Lezer author), consistent with it being one of many small, focused @codemirror/lang-* packages maintained as part of that ecosystem rather than independently. API Design - The public surface is intentionally minimal: one factory function (xml(conf?)) covers the common case with zero configuration, while power users opt into schema-aware completions by passing typed elements/attributes config objects. This mirrors the consistent, predictable API shape shared across every official @codemirror/lang-* package, so switching between supported languages requires no relearning.

Used by 10 apps in this directory

Python
55%
Other

authentik

Authentication · Security

25,758

The self-hosted Identity Provider that replaces Okta, Auth0, and Entra ID with a unified SSO platform supporting SAML, OAuth2/OIDC, LDAP, RADIUS, and WebAuthn.

View details
92
Repo Health
81
Technical
66
Dependency
Built with
Python 55%
TypeScript 36%
Updated 4 days ago
Rust
65%
Other

GitButler

AI Development · Developer Tools · Devops

21,726

Git, but better — a modern version control client with stacked branches, parallel workflows, unlimited undo, and first-class support for AI-powered development.

View details
89
Repo Health
84
Technical
66
Dependency
Built with
Rust 65%
TypeScript 22%
Svelte 10%
Updated 4 days ago
TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,529

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
65
Dependency
Built with
TypeScript 67%
Vue 25%
Updated 6 days ago
TypeScript
100%
Apache 2.0

ILLA Builder

Design Tools · Developer Tools · Low Code Platforms

12,327

Open-source low-code platform for building internal tools with drag-and-drop UI, reactive data bindings, and real-time collaboration.

View details
56
Repo Health
71
Technical
63
Dependency
Built with
TypeScript 100%
Updated 4 months ago
Python
51%
AGPL 3.0

LearnHouse

CMS · Learning Management

2,301

Open-source LMS with AI tutoring, real-time collaboration boards, live code execution, and built-in course monetization — self-hosted in minutes.

View details
90
Repo Health
77
Technical
66
Dependency
Built with
Python 51%
TypeScript 48%
Updated 5 days ago
Go
68%
MIT

nginx ignition

Developer Tools · Devops

2,139

A modern web UI for nginx that eliminates config file editing with visual virtual hosts, SSL automation, Docker integrations, and real-time traffic analytics.

View details
69
Repo Health
80
Technical
71
Dependency
Built with
Go 68%
TypeScript 29%
Updated 1 weeks ago
Python
75%
AGPL 3.0

OpenViking

AI Development · AI Memory · Databases

38,819

An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.

View details
85
Repo Health
75
Technical
64
Dependency
Built with
Python 75%
Rust 12%
Updated 4 days ago
TypeScript
65%
MIT

Scalar

Developer Tools

16,198

Beautiful, interactive OpenAPI documentation with a built-in offline-first API client and multi-language code generation — all in one open-source platform.

View details
90
Repo Health
89
Technical
65
Dependency
Built with
TypeScript 65%
Vue 30%
Updated 4 days ago
TypeScript
97%
Other

Sourcebot

AI Code Assistants · Developer Tools · Search

3,952

A self-hosted, AI-powered code search engine that indexes every repo across GitHub, GitLab, Bitbucket, Gitea, Gerrit, and Azure DevOps, so both engineers and coding agents can search, browse, and ask questions about your codebase from one place.

View details
85
Repo Health
83
Technical
62
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers