/commands/prettier/prettier-write-check
prettier --write and --check: format files from the command line
verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated 2026-10-20
- tool
- Prettier
- versions
- Prettier 3.x
- os
- any
npx prettier . --write rewrites every supported file in the project with Prettier's formatting. npx prettier . --check only reports files that are not formatted and exits with status 1 if there are any, which is what you want in CI and pre-commit hooks.
Check, then write
npm init -y >/dev/null
npm install --silent --no-audit --no-fund prettier@3 >/dev/null 2>&1
printf 'const greet = (name)=>{return "hi "+name}\n' > app.js
npx prettier . --check; echo "check exit status: $?"
npx prettier . --write
cat app.js
npx prettier . --check; echo "check exit status: $?"Output
Checking formatting...
[warn] app.js
[warn] Code style issues found in the above file. Run Prettier with --write to fix.
check exit status: 1
app.js 26ms
package-lock.json 4ms (unchanged)
package.json 2ms (unchanged)
const greet = (name) => {
return "hi " + name;
};
Checking formatting...
All matched files use Prettier code style!
check exit status: 0Configure it
{
"singleQuote": true,
"printWidth": 100,
"trailingComma": "all"
}dist/
coverage/
package-lock.jsonPrettier also reads .gitignore by default, so ignored build output is skipped.
Useful options
| Option | Effect |
|---|---|
| --write | format files in place |
| --check | list unformatted files; exit 1 if any |
| --list-different | print only the names of unformatted files |
| --cache | skip unchanged files on later runs |
| --ignore-unknown | do not fail on files Prettier cannot parse |
| --config path | use a specific config file |
Sources
Related pages
flags · eslinteslint --fix: automatically fix lint problemsnpx eslint . --fix applies the fixes that rules provide, such as let to const, and reports what it cannot fix. Preview changes first with --fix-dry-run.changes · tailwindcssTailwind CSS v3 to v4: renamed utilities and breaking changesTailwind CSS v4 moves config into CSS with @import and @theme, splits the PostCSS plugin and CLI, renames shadow, blur and rounded scales, needs Safari 16.4.config · vitevite.config server.proxy: proxy API calls in the dev serverserver.proxy in vite.config.js forwards dev-server requests such as /api to a backend to avoid CORS in development. Targets, rewrite, changeOrigin, ws.