Skip to content
Latchkey

Prettier semi: Semicolons On or Off

semi decides whether Prettier prints semicolons at the ends of statements; the default is true.

Semicolons are a style debate Prettier settles with one boolean. Set it once and the whole codebase agrees, which is the point.

What it does

semi (default true) adds a semicolon at the end of every statement. With semi false, Prettier omits them and instead prepends a semicolon to the few lines that would otherwise be misinterpreted (lines starting with a parenthesis, bracket, or backtick), so the no-semi style stays safe.

Common usage

.prettierrc.json
// .prettierrc.json
{ "semi": false }

// input
const a = 1;
const b = 2;
// output with semi:false
const a = 1
const b = 2

Options

SettingWhat it does
semi: true (default)Print semicolons at statement ends
semi: falseOmit them, adding leading guards where needed
--no-semiSet semi to false on the CLI

In CI

If you also use ESLint, make sure its semi rule agrees with Prettier or the two tools fight. The recommended setup is eslint-config-prettier, which disables the stylistic ESLint rules that overlap with Prettier so only Prettier decides semicolons.

Common errors in CI

A flood of "Code style issues found" right after setting semi:false means the codebase has not been reformatted yet; run prettier --write . once and commit. If ESLint reports semi errors that Prettier just removed, your ESLint config still has the stylistic rule on; add eslint-config-prettier last in extends.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →