Prettier commands
Opinionated code formatter supporting multiple languages
Formatting Files
prettier --write .Format all supported files in the current directory recursively
prettier --write srcFormat all supported files in the src directory recursively
prettier --write src/index.tsFormat a single specific file in place
prettier --write "src/**/*.ts"Format all TypeScript files in src recursively
prettier --write "src/**/*.{ts,tsx}"Format all TypeScript and TSX files in src recursively
prettier --write "**/*.{js,jsx,ts,tsx}"Format all JS and TS files across the entire project
prettier --write "**/*.{js,ts,json,css,md}"Format JS, TS, JSON, CSS, and Markdown files across the project
prettier --write "src/**" "tests/**"Format all files in both src and tests directories
prettier --write . --ignore-path .gitignoreFormat all files using .gitignore as the ignore rule source
prettier --write . --ignore-path .prettierignoreFormat all files using a specific .prettierignore file
prettier --write . --ignore-unknownFormat supported files, silently skipping unsupported file types
prettier --write . --no-error-on-unmatched-patternFormat files without erroring if a glob pattern matches nothing
prettier --write . --log-level=warnFormat files showing only warnings and errors in output
prettier --write . --log-level=silentFormat files suppressing all output
prettier --write . --log-level=debugFormat files with verbose debug output for troubleshooting
Checking Files
prettier --check .Check if all supported files in the current directory are formatted
prettier --check srcCheck if all supported files in the src directory are formatted
prettier --check src/index.tsCheck if a single specific file is formatted correctly
prettier --check "src/**/*.ts"Check if all TypeScript files in src are formatted
prettier --check "**/*.{js,ts,json,css,md}"Check formatting of JS, TS, JSON, CSS, and Markdown files
prettier --check . --ignore-path .gitignoreCheck formatting of files using .gitignore as the ignore source
prettier --check . --ignore-unknownCheck formatting, silently skipping unsupported file types
prettier --check . --log-level=warnCheck formatting showing only warnings and errors
Printing & Stdout
prettier src/index.tsPrint the formatted output of a file to stdout without writing it
prettier --stdin-filepath src/index.tsFormat stdin input treating it as the given file path and print to stdout
cat src/index.ts | prettier --stdin-filepath index.tsPipe a file through prettier via stdin and print formatted output
prettier src/index.ts --write=falseExplicitly print formatted output to stdout without writing to disk
Formatting Options
prettier --write . --print-width=100Format files with a line wrap width of 100 characters
prettier --write . --print-width=120Format files with a line wrap width of 120 characters
prettier --write . --tab-width=2Format files using 2 spaces per indentation level
prettier --write . --tab-width=4Format files using 4 spaces per indentation level
prettier --write . --use-tabsFormat files indenting with tabs instead of spaces
prettier --write . --no-use-tabsFormat files indenting with spaces instead of tabs
prettier --write . --single-quoteFormat files using single quotes instead of double quotes
prettier --write . --no-single-quoteFormat files using double quotes instead of single quotes
prettier --write . --jsx-single-quoteFormat JSX attributes using single quotes
prettier --write . --no-jsx-single-quoteFormat JSX attributes using double quotes
prettier --write . --trailing-comma=allAdd trailing commas wherever valid in ES5 and function parameters
prettier --write . --trailing-comma=es5Add trailing commas only where valid in ES5 syntax
prettier --write . --trailing-comma=noneRemove all trailing commas from formatted output
prettier --write . --no-semiFormat files omitting semicolons at the end of statements
prettier --write . --semiFormat files adding semicolons at the end of statements
prettier --write . --bracket-spacingPrint spaces between brackets in object literals
prettier --write . --no-bracket-spacingOmit spaces between brackets in object literals
prettier --write . --bracket-same-linePut the closing bracket of multiline JSX elements on the last line
prettier --write . --no-bracket-same-linePut the closing bracket of multiline JSX elements on a new line
prettier --write . --arrow-parens=alwaysAlways include parentheses around arrow function arguments
prettier --write . --arrow-parens=avoidOmit parentheses around single arrow function arguments when possible
prettier --write . --prose-wrap=alwaysWrap prose in Markdown and similar files at the print width
prettier --write . --prose-wrap=neverDo not wrap prose in Markdown files regardless of line length
prettier --write . --prose-wrap=preservePreserve the original wrapping of prose in Markdown files
prettier --write . --html-whitespace-sensitivity=cssRespect CSS display property for HTML whitespace handling
prettier --write . --html-whitespace-sensitivity=strictTreat all whitespace as significant in HTML formatting
prettier --write . --html-whitespace-sensitivity=ignoreIgnore all whitespace sensitivity in HTML formatting
prettier --write . --vue-indent-script-and-styleIndent script and style blocks inside Vue single-file components
prettier --write . --no-vue-indent-script-and-styleDo not indent script and style blocks inside Vue single-file components
prettier --write . --end-of-line=lfFormat files using LF line endings
prettier --write . --end-of-line=crlfFormat files using CRLF line endings
prettier --write . --end-of-line=crFormat files using CR line endings
prettier --write . --end-of-line=autoMaintain existing line endings in each file
prettier --write . --embedded-language-formatting=autoFormat embedded code blocks in supported languages automatically
prettier --write . --embedded-language-formatting=offDisable formatting of embedded code blocks
prettier --write . --single-attribute-per-lineEnforce one HTML or JSX attribute per line in multiline elements
prettier --write . --experimental-ternariesFormat ternary expressions using the experimental curious ternary style
Parser & Language
prettier --write src/index.ts --parser=typescriptFormat a file explicitly using the TypeScript parser
prettier --write src/index.js --parser=babelFormat a file explicitly using the Babel JavaScript parser
prettier --write src/index.jsx --parser=babelFormat a JSX file explicitly using the Babel parser
prettier --write src/index.tsx --parser=babel-tsFormat a TSX file explicitly using the Babel TypeScript parser
prettier --write src/style.css --parser=cssFormat a file explicitly using the CSS parser
prettier --write src/style.scss --parser=scssFormat a file explicitly using the SCSS parser
prettier --write src/style.less --parser=lessFormat a file explicitly using the Less parser
prettier --write data.json --parser=jsonFormat a file explicitly using the JSON parser
prettier --write data.json --parser=json5Format a file explicitly using the JSON5 parser
prettier --write README.md --parser=markdownFormat a file explicitly using the Markdown parser
prettier --write docs/page.mdx --parser=mdxFormat a file explicitly using the MDX parser
prettier --write index.html --parser=htmlFormat a file explicitly using the HTML parser
prettier --write schema.graphql --parser=graphqlFormat a file explicitly using the GraphQL parser
prettier --write .prettierrc --parser=jsonFormat a config file without an extension using the JSON parser
prettier --write config.yaml --parser=yamlFormat a file explicitly using the YAML parser
Configuration
prettier --write . --config .prettierrcFormat files using a specific Prettier configuration file
prettier --write . --config prettier.config.jsFormat files using a JavaScript Prettier configuration file
prettier --write . --no-configFormat files ignoring any discovered configuration files
prettier --write . --config-precedence=prefer-filePrefer config file options over CLI options when both are present
prettier --write . --config-precedence=cli-overrideLet CLI options override config file options when both are present
prettier --write . --config-precedence=file-overrideLet config file options override CLI options entirely
prettier --find-config-path src/index.tsPrint the path to the configuration file resolved for a given file
prettier --write . --editorconfigApply options from .editorconfig when formatting files
prettier --write . --no-editorconfigIgnore .editorconfig settings when formatting files
prettier --write . --plugin=prettier-plugin-tailwindcssFormat files using a specific Prettier plugin
prettier --write . --plugin=@prettier/plugin-phpFormat files using the Prettier PHP plugin
prettier --write . --plugin=prettier-plugin-svelteFormat files using the Prettier Svelte plugin
Info & Debugging
prettier --versionDisplay the currently installed version of Prettier
prettier --helpDisplay help information and all available CLI options
prettier --support-infoPrint a list of all languages and file types Prettier supports
prettier --support-info --jsonPrint supported languages and file types as JSON
prettier --file-info src/index.tsShow the parser and config that Prettier would use for a given file
prettier --file-info src/index.ts --jsonShow file info for a given file in JSON format
prettier --file-info src/index.ts --ignore-path .prettierignoreShow file info using a specific ignore file
prettier --check . --log-level=debugCheck formatting with verbose debug output for troubleshooting
CI & Integration
prettier --check . --ignore-path .gitignoreCheck formatting in CI using .gitignore as the ignore source
prettier --check "src/**/*.{ts,tsx,js,jsx}" --log-level=warnCheck formatting of source files in CI showing only warnings and errors
prettier --write . --ignore-unknown --log-level=warnFormat all files in CI skipping unknown types and reducing noise
prettier --check . --no-error-on-unmatched-patternCheck formatting without failing if a glob pattern matches no files
prettier --write "**/*.{ts,tsx,js,jsx,json,css,md}" --ignore-path .gitignore --log-level=warnFormat all common file types in CI using gitignore and minimal logging