JavaScript template engine libraries

Updated Nov 2026

JavaScript template engine libraries render HTML or text by filling a template with data in Node.js and the browser. An engine either embeds plain JavaScript in the template or uses its own tag syntax with helpers, partials, and layout inheritance. These libraries let web servers, static site generators, and email tools build pages from shared templates.

Popularity

EJS has the most monthly downloads among dedicated template engines in this comparison, at 223.7M.

LibraryMonthly downloadsStarsLast releaseLicense
Lodash
801.2M
Not on GitHubApr 2026MIT
EJS
230.1M
8.1KOct 2026Apache-2.0
Handlebars
219.7M
18.7KOct 2026MIT
Underscore
166.4M
Not on GitHubFeb 2026MIT
mustache
98.2M
16.7KMar 2021MIT
Eta
42.4M
Not on GitHubApr 2026MIT
Pug
19.8M
Not on GitHubMar 2026MIT
Nunjucks
19.3M
9.0KApr 2023BSD-2-Clause
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryEscapes interpolationAsync renderingFile-loading API
LodashUnsupportedUnsupportedUnsupported
EJSBuilt-inBuilt-inBuilt-in
HandlebarsBuilt-inUnsupportedBuilt-in
UnderscoreUnsupportedUnsupportedUnsupported
mustacheBuilt-inUnsupportedUnsupported
EtaBuilt-inBuilt-inBuilt-in
PugBuilt-inUnsupportedBuilt-in
NunjucksBuilt-inBuilt-inBuilt-in
Built-inNot supported

Libraries and code examples

Compiles text templates with configurable delimiters as one part of a broad utility library.

Downloads / mo
801.2M
Last release
4.18.1
License
MIT

Quickstart

From lodash.js
$ npm install lodash@4.18.1
const _ = require('lodash');

const render = _.template('Hello <%= name %>!');
const output = render({ name: 'Ada' });

Lodash examples

From open-source projects on GitHub

Generates template output using JavaScript control flow and escaped or raw interpolation.

Downloads / mo
230.1M
Stars
8.1K
Last release
7.0.2
License
Apache-2.0

Strengths

  • Uses JavaScript inside templates. Write loops and conditions with normal JavaScript.
  • Changes delimiters per template. Choose delimiters per render instead of changing global settings.

Limitations

  • Templates need trusted authors. Do not accept unrestricted template source from end users.
  • Layouts rely on includes. Compose headers and footers; EJS does not provide layout blocks.

Quickstart

From README.md
$ npm install ejs@7.0.2
const ejs = require('ejs');

const output = ejs.render('Hello <%= name %>!', { name: 'Ada' });

EJS examples

From open-source projects on GitHub

Generates HTML or other template text from an input object.

Downloads / mo
219.7M
Stars
18.7K
Last release
4.7.10
License
MIT

Strengths

  • Precompiles templates for client execution. Generate template code before deploying the rendering runtime.
  • Reuses registered partial templates. Register partials once and call them from other templates.

Limitations

  • Missing fields are silently ignored. Enable strict to throw when template data is missing.
  • Prototype properties are blocked. Convert model instances to plain objects before rendering.

Quickstart

From README.md
$ npm install handlebars@4.7.10
const Handlebars = require('handlebars');

const render = Handlebars.compile('Hello {{name}}!');
const output = render({ name: 'Ada' });

Handlebars examples

From open-source projects on GitHub

Compiles text templates with evaluate, interpolate, and escape tags as one part of a utility toolkit.

Downloads / mo
166.4M
Last release
1.13.8
License
MIT

Quickstart

From template.js
$ npm install underscore@1.13.8
const _ = require('underscore');

const render = _.template('Hello <%= name %>!');
const output = render({ name: 'Ada' });

Underscore examples

From open-source projects on GitHub
function() {
      this.$el.html(this.template(this.model.toJSON()));
      this.$el.toggleClass('done', this.model.get('done'));
      this.input = this.$('.edit');
      return this;
    }

Expands template tags using values supplied in an object.

Downloads / mo
98.2M
Stars
16.7K
Last release
4.2.0
License
MIT

Strengths

  • Reuses partials at runtime. Supply partial text by name when rendering nested templates.
  • Changes tag delimiters inline. Switch delimiters when braces conflict with other template content.

Limitations

  • Complex branching belongs in data. Prepare decisions in view values or helper functions.
  • Missing keys render nothing. Validate required input fields before rendering.

Quickstart

From README.md
$ npm install mustache@4.2.0
const Mustache = require('mustache');

const output = Mustache.render('Hello {{name}}!', { name: 'Ada' });

mustache examples

From open-source projects on GitHub
async compile(str) {
  let partials = await super.getPartials();

  return function (data) {
    return this.render(str, data, partials).trim();
  }.bind(this.mustacheLib);
}

Renders embedded JavaScript templates with escaping by default, async methods, includes, and layouts.

Downloads / mo
42.4M
Last release
4.6.0
License
MIT

Quickstart

From README.md
$ npm install eta@4.6.0
const { Eta } = require('eta');

const eta = new Eta();
const output = eta.renderString('Hello <%= it.name %>!', { name: 'Ada' });

Eta examples

From open-source projects on GitHub
export async function compileSSGTemplate(
  template: string,
): Promise<SSGTemplateCompiled> {
  const eta = new Eta({rmWhitespace: true});
  const compiledTemplate = eta.compile(template.trim());

  return (data: SSGTemplateData) => eta.render(compiledTemplate, data);
}

Compiles a whitespace-sensitive template language to HTML with includes and block inheritance.

Downloads / mo
19.8M
Last release
3.0.4
License
MIT

Quickstart

From README.md
$ npm install pug@3.0.4
const pug = require('pug');

const output = pug.render('p Hello #{name}!', { name: 'Ada' });

Pug examples

From open-source projects on GitHub

Renders templates with reusable layouts and overridable blocks.

Downloads / mo
19.3M
Stars
9.0K
Last release
3.2.4
License
BSD-2-Clause

Strengths

  • Supports template inheritance. Use extends and blocks to share page layouts.
  • Supports asynchronous template work. Add asynchronous filters and loaders for data-dependent rendering.

Limitations

  • Default API shares one configuration. Create an explicit Environment when instances need separate settings.
  • Async loaders need async rendering. Use callback-based rendering with asynchronous loaders.

Quickstart

From api.md
$ npm install nunjucks@3.2.4
const nunjucks = require('nunjucks');

const output = nunjucks.renderString('Hello {{ name }}!', { name: 'Ada' });

Nunjucks examples

From open-source projects on GitHub

FAQ

EJS suits Express apps that want plain JavaScript inside templates. Handlebars suits teams that want logic-light templates with helpers and precompilation. Nunjucks suits sites that share layouts through block inheritance.

EJS is an embedded JavaScript template engine. Templates mix HTML with JavaScript control flow and escaped or raw output tags.

EJS runs ordinary JavaScript inside templates. Handlebars keeps logic out of templates and moves it into registered helpers.

Handlebars is a Mustache-family template engine with escaped interpolation, helpers, partials, and precompiled templates.

Mustache.js keeps templates logic-less with sections and partials. Handlebars accepts Mustache templates and adds helpers, block expressions, and precompilation.

For coding agents

Found your template engine library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official