prettier-plugin-sfmc

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

Prettier plugin for Salesforce Marketing Cloud formatting AMPscript, SSJS, and SQL. v0.4.1 supports Prettier 3.7+. Key differentiator: unified formatting for SFMC-specific languages with auto-discovery, cross-block control flow handling, and embedded prettier-plugin-sql for T-SQL. Release cadence is frequent (minor/patch monthly).

error Error: Cannot find module 'prettier-plugin-sfmc'
cause Plugin not installed or not in node_modules.
fix
npm install prettier-plugin-sfmc --save-dev
error Cannot read properties of undefined (reading 'defaultOptions')
cause Prettier version lower than 3.7.0.
fix
Upgrade Prettier to 3.7+.
breaking Requires Prettier >=3.7.0; older versions will not load the plugin.
fix Upgrade Prettier to 3.7+.
deprecated ampscriptBlockLineBreaks option default changed from true to false in v0.4.0.
fix To preserve old behavior, set `ampscriptBlockLineBreaks: true` in config.
gotcha Plugin auto-discovers but only for listed file extensions. Custom extensions require explicit parser.
fix Use `overrides` in .prettierrc for custom file types.
gotcha SQL formatting uses embedded prettier-plugin-sql with T-SQL presets; may not match all SQL dialects.
fix Override SQL options via prettier-plugin-sql config or disable SQL formatting.
gotcha SSJS files use Prettier's JavaScript parser; SFMC-specific options like ampScriptSpacing do not apply.
fix Configure JavaScript options separately in .prettierrc.
npm install prettier-plugin-sfmc
yarn add prettier-plugin-sfmc
pnpm add prettier-plugin-sfmc

Install, configure, and run Prettier with SFMC plugin to format AMPscript, SSJS, and SQL files.

// Install
npm install --save-dev prettier prettier-plugin-sfmc

// .prettierrc
{
  "plugins": ["prettier-plugin-sfmc"],
  "ampscriptKeywordCase": "upper",
  "ampscriptQuoteStyle": "single"
}

// Format all files
npx prettier --write "**/*.{ampscript,amp,ssjs,sql,html}"