Prettier Plugin for EJS

raw JSON →
1.0.3 verified Sat Apr 25 auth: no javascript

A Prettier plugin that formats EJS (Embedded JavaScript) templates within HTML files. Current stable version 1.0.3 supports Prettier 2.x and 3.x. It works by marking EJS tags as comments and relying on Prettier's built-in HTML parser, so it does not have its own parser — this keeps it lightweight but means EJS tags containing `>` are ignored. Compared to alternatives like prettier-plugin-ejs-by-ecmel, this is the most popular and maintained option. Release cadence is irregular, with infrequent updates; the plugin has been stable for years without major changes.

error Cannot find module 'prettier-plugin-ejs'
cause Plugin not installed or Prettier cannot resolve it.
fix
Run npm install --save-dev prettier-plugin-ejs and ensure node_modules is present.
error The plugin "prettier-plugin-ejs" did not export a factory function.
cause Using an incompatible version of Prettier (v3 vs v2 plugin API).
fix
Update to prettier-plugin-ejs@1.0.0+ for Prettier v2/v3 support.
error Error: Cannot parse inline EJS tags with `>`
cause The plugin does not handle EJS tags containing `>` because it marks them as comments.
fix
Escape > as > or reformat to avoid it inside EJS expressions.
gotcha EJS tags containing the greater-than symbol (`>`) are ignored and not formatted.
fix Avoid using > inside EJS delimiters; refactor to use alternatives like `gt;` or separate logic.
gotcha Prettier v3 requires explicit plugin loading; it is not auto-loaded like in v2.
fix Use `--plugin=prettier-plugin-ejs` or add to plugins array in config.
deprecated Upgrading from v0.x to v1.0.0 may require configuration changes due to breaking changes in plugin API.
fix Update to v1.0.0 and ensure Prettier >=2.0. Follow migration notes in changelog.
npm install prettier-plugin-ejs
yarn add prettier-plugin-ejs
pnpm add prettier-plugin-ejs

Installs the plugin and formats all HTML files with EJS tags using Prettier v3.

npm install --save-dev prettier prettier-plugin-ejs
# Prettier v3 usage:
prettier --plugin=prettier-plugin-ejs --write "**/*.html"
# Or create .prettierrc:
echo '{"plugins": ["prettier-plugin-ejs"]}' > .prettierrc