Mustache.js

Logic-less {{mustache}} templates for JavaScript, running anywhere JS runs.

Library
npm
v4.2.0
16,721 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
53 /100 Fair
Development Activity 0
Maintenance 20
Community 92
Maturity 60
Momentum 40

Technical Analysis

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

Mustache.js is the JavaScript implementation of the language-agnostic Mustache templating system. It expands {{tag}} placeholders in a template string using values from a plain object or array, and deliberately has no if-statements, else-clauses, or loops beyond section blocks — templates stay declarative and portable across the many other Mustache implementations (Ruby, Python, PHP, Java, and more).

The library ships as a single dependency-free file with CommonJS, AMD, and ECMAScript module builds, plus a small CLI. It’s commonly used to render HTML fragments in the browser, generate server-side output in Node.js, or produce non-HTML text such as config files and emails from a shared data context.

What You Get

  • A zero-dependency Mustache.render(template, view, partials, tags) API with automatic HTML escaping and an overridable Mustache.escape function
  • Section tags ({{#section}}) for lists, booleans, and lambda-style function values, plus inverted sections ({{^section}}) for falsy/empty cases
  • Partial template support ({{> partial}}) that inherits the calling context, resolved at render time so recursive partials work
  • Custom delimiter syntax ({{=<% %>=}}) for templating non-HTML/non-mustache-conflicting formats
  • A bundled command-line tool (bin/mustache) for rendering templates outside of a JS program
  • CommonJS, AMD, and native ES module builds (mustache.js / mustache.mjs) plus a minified browser build

Common Use Cases

  • Rendering HTML fragments client-side from JSON data without pulling in a full frontend framework
  • Generating server-rendered HTML, emails, or CLI output in Node.js from a shared template language
  • Sharing one template format across a polyglot stack, since Mustache implementations exist for most languages
  • Producing non-HTML text artifacts — config files, source code stubs, or plain-text reports — from a data context

Under The Hood

Architecture — The library is organized as a small pipeline in a single file (mustache.js, ~760 lines): parseTemplate tokenizes a template string with regex-driven scanning via a Scanner object, nestTokens/squashTokens fold flat tokens into a nested tree for sections, a Context class implements the scope-chain lookup used to resolve {{tag}} values (falling back to parentContext when a key is missing locally, per line 375), and a Writer class (line 481) owns template parsing/caching plus the actual render/renderTokens walk that turns the token tree and a Context into output text. The module-level mustache object is a Writer instance, so Mustache.render is really Writer.prototype.render.

Tech Stack — Plain ES5-compatible JavaScript with no runtime dependencies at all (package.json lists zero dependencies); devDependencies are limited to its own build/test tooling (mocha, chai, eslint, rollup, uglify-js, zuul for browser tests). The exports map in package.json ships both a CommonJS (mustache.js) and an ES module (mustache.mjs) build built via rollup, alongside a minified mustache.min.js for direct browser use, and a small CLI entry at bin/mustache.

Code Quality — Tests live under test/ and are run with mocha (test-unit) plus a dedicated test-lint eslint pass; notably the suite pulls in the official cross-language mustache-spec test fixtures (test/mustache-spec-test.js, test/spec/) so the implementation is validated against the same conformance suite used by other Mustache ports, in addition to hand-written unit tests for context, parsing, scanning, partials, and rendering. Functions are small, single-purpose, and consistently documented with JSDoc-style comments explaining intent (e.g. the null-safe hasProperty/primitiveHasOwnProperty helpers).

API Design — The public surface is deliberately tiny: one primary function (Mustache.render(template, view, partials, tags)) covers the common case with zero configuration required, and power users can reach Mustache.parse/Writer for caching control or override Mustache.escape/Mustache.tags globally. This keeps boilerplate minimal — a single require('mustache') and one render() call is enough to get output — at the cost of a slightly older callback-free, non-chainable API style compared to newer templating libraries.

Used by 21 apps in this directory

TypeScript
100%
Other

Activepieces

AI Assistants · Automation · Mcp

24,756

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
64
Dependency
Built with
TypeScript 100%
Updated 4 days ago
TypeScript
82%
Other

AFFiNE

Collaboration · Note Taking · Productivity

73,040

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
67
Dependency
Built with
TypeScript 82%
Rust 11%
Updated 5 days ago
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,916

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
90
Repo Health
77
Technical
61
Dependency
Built with
TypeScript 97%
Updated 6 days ago
TypeScript
84%
Apache 2.0

Continue

AI Code Assistants · AI Development · Automation

36,049

Open-source coding agent for VS Code, JetBrains, and CLI with support for 30+ LLM providers.

View details
73
Repo Health
88
Technical
62
Dependency
Built with
TypeScript 84%
Updated 5 days ago
Go
62%
Apache 2.0

Harness Open Source

Code Editors · Developer Tools · Devops

38,450

A unified open source DevOps platform combining Git hosting, CI/CD pipelines, cloud development environments, and artifact registries in a single self-hosted system.

View details
89
Repo Health
79
Technical
64
Dependency
Built with
Go 62%
TypeScript 33%
Updated 1 weeks ago
TypeScript
77%
Other

Joplin

Note Taking

56,513

The privacy-first, open-source note-taking app with end-to-end encrypted sync, AI assistance, and a powerful plugin ecosystem across every platform.

View details
93
Repo Health
87
Technical
60
Dependency
Built with
TypeScript 77%
JavaScript 14%
Updated 5 days ago
TypeScript
50%

Kener

Devops · Monitoring

5,181

Stunning, self-hosted status pages with real-time uptime monitoring, incident management, and multi-channel notifications in a single Docker container.

View details
86
Repo Health
76
Technical
67
Dependency
Built with
TypeScript 50%
Svelte 47%
Updated 2 weeks ago
TypeScript
98%
Other

Kibana

Analytics · Monitoring

21,301

Your open source window into the Elastic Stack — query, visualize, and act on data stored in Elasticsearch with real-time dashboards, AI-assisted search, and automated alerting.

View details
98
Repo Health
87
Technical
63
Dependency
Built with
TypeScript 98%
Updated 4 days ago
TypeScript
64%
Apache 2.0

Laminar

AI Development · Monitoring

3,285

Open-source observability platform purpose-built for AI agents — trace, evaluate, debug, and monitor at scale with SQL access and real-time replay.

View details
85
Repo Health
76
Technical
66
Dependency
Built with
TypeScript 64%
Rust 34%
Updated 5 days 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