Prettier
Prettier

Formatting Files

Format all supported files in the current directory recursively

$prettier --write .

Format all supported files in the src directory recursively

$prettier --write src

Format a single specific file in place

$prettier --write src/index.ts

Format all TypeScript files in src recursively

$prettier --write "src/**/*.ts"

Format all TypeScript and TSX files in src recursively

$prettier --write "src/**/*.{ts,tsx}"

Format all JS and TS files across the entire project

$prettier --write "**/*.{js,jsx,ts,tsx}"

Format JS, TS, JSON, CSS, and Markdown files across the project

$prettier --write "**/*.{js,ts,json,css,md}"

Format all files in both src and tests directories

$prettier --write "src/**" "tests/**"

Format all files using .gitignore as the ignore rule source

$prettier --write . --ignore-path .gitignore

Format all files using a specific .prettierignore file

$prettier --write . --ignore-path .prettierignore

Format supported files, silently skipping unsupported file types

$prettier --write . --ignore-unknown

Format files without erroring if a glob pattern matches nothing

$prettier --write . --no-error-on-unmatched-pattern

Format files showing only warnings and errors in output

$prettier --write . --log-level=warn

Format files suppressing all output

$prettier --write . --log-level=silent

Format files with verbose debug output for troubleshooting

$prettier --write . --log-level=debug

Checking Files

Check if all supported files in the current directory are formatted

$prettier --check .

Check if all supported files in the src directory are formatted

$prettier --check src

Check if a single specific file is formatted correctly

$prettier --check src/index.ts

Check if all TypeScript files in src are formatted

$prettier --check "src/**/*.ts"

Check formatting of JS, TS, JSON, CSS, and Markdown files

$prettier --check "**/*.{js,ts,json,css,md}"

Check formatting of files using .gitignore as the ignore source

$prettier --check . --ignore-path .gitignore

Check formatting, silently skipping unsupported file types

$prettier --check . --ignore-unknown

Check formatting showing only warnings and errors

$prettier --check . --log-level=warn

Printing & Stdout

Print the formatted output of a file to stdout without writing it

$prettier src/index.ts

Format stdin input treating it as the given file path and print to stdout

$prettier --stdin-filepath src/index.ts

Pipe a file through prettier via stdin and print formatted output

$cat src/index.ts | prettier --stdin-filepath index.ts

Explicitly print formatted output to stdout without writing to disk

$prettier src/index.ts --write=false

Formatting Options

Format files with a line wrap width of 100 characters

$prettier --write . --print-width=100

Format files with a line wrap width of 120 characters

$prettier --write . --print-width=120

Format files using 2 spaces per indentation level

$prettier --write . --tab-width=2

Format files using 4 spaces per indentation level

$prettier --write . --tab-width=4

Format files indenting with tabs instead of spaces

$prettier --write . --use-tabs

Format files indenting with spaces instead of tabs

$prettier --write . --no-use-tabs

Format files using single quotes instead of double quotes

$prettier --write . --single-quote

Format files using double quotes instead of single quotes

$prettier --write . --no-single-quote

Format JSX attributes using single quotes

$prettier --write . --jsx-single-quote

Format JSX attributes using double quotes

$prettier --write . --no-jsx-single-quote

Add trailing commas wherever valid in ES5 and function parameters

$prettier --write . --trailing-comma=all

Add trailing commas only where valid in ES5 syntax

$prettier --write . --trailing-comma=es5

Remove all trailing commas from formatted output

$prettier --write . --trailing-comma=none

Format files omitting semicolons at the end of statements

$prettier --write . --no-semi

Format files adding semicolons at the end of statements

$prettier --write . --semi

Print spaces between brackets in object literals

$prettier --write . --bracket-spacing

Omit spaces between brackets in object literals

$prettier --write . --no-bracket-spacing

Put the closing bracket of multiline JSX elements on the last line

$prettier --write . --bracket-same-line

Put the closing bracket of multiline JSX elements on a new line

$prettier --write . --no-bracket-same-line

Always include parentheses around arrow function arguments

$prettier --write . --arrow-parens=always

Omit parentheses around single arrow function arguments when possible

$prettier --write . --arrow-parens=avoid

Wrap prose in Markdown and similar files at the print width

$prettier --write . --prose-wrap=always

Do not wrap prose in Markdown files regardless of line length

$prettier --write . --prose-wrap=never

Preserve the original wrapping of prose in Markdown files

$prettier --write . --prose-wrap=preserve

Respect CSS display property for HTML whitespace handling

$prettier --write . --html-whitespace-sensitivity=css

Treat all whitespace as significant in HTML formatting

$prettier --write . --html-whitespace-sensitivity=strict

Ignore all whitespace sensitivity in HTML formatting

$prettier --write . --html-whitespace-sensitivity=ignore

Indent script and style blocks inside Vue single-file components

$prettier --write . --vue-indent-script-and-style

Do not indent script and style blocks inside Vue single-file components

$prettier --write . --no-vue-indent-script-and-style

Format files using LF line endings

$prettier --write . --end-of-line=lf

Format files using CRLF line endings

$prettier --write . --end-of-line=crlf

Format files using CR line endings

$prettier --write . --end-of-line=cr

Maintain existing line endings in each file

$prettier --write . --end-of-line=auto

Format embedded code blocks in supported languages automatically

$prettier --write . --embedded-language-formatting=auto

Disable formatting of embedded code blocks

$prettier --write . --embedded-language-formatting=off

Enforce one HTML or JSX attribute per line in multiline elements

$prettier --write . --single-attribute-per-line

Format ternary expressions using the experimental curious ternary style

$prettier --write . --experimental-ternaries

Parser & Language

Format a file explicitly using the TypeScript parser

$prettier --write src/index.ts --parser=typescript

Format a file explicitly using the Babel JavaScript parser

$prettier --write src/index.js --parser=babel

Format a JSX file explicitly using the Babel parser

$prettier --write src/index.jsx --parser=babel

Format a TSX file explicitly using the Babel TypeScript parser

$prettier --write src/index.tsx --parser=babel-ts

Format a file explicitly using the CSS parser

$prettier --write src/style.css --parser=css

Format a file explicitly using the SCSS parser

$prettier --write src/style.scss --parser=scss

Format a file explicitly using the Less parser

$prettier --write src/style.less --parser=less

Format a file explicitly using the JSON parser

$prettier --write data.json --parser=json

Format a file explicitly using the JSON5 parser

$prettier --write data.json --parser=json5

Format a file explicitly using the Markdown parser

$prettier --write README.md --parser=markdown

Format a file explicitly using the MDX parser

$prettier --write docs/page.mdx --parser=mdx

Format a file explicitly using the HTML parser

$prettier --write index.html --parser=html

Format a file explicitly using the GraphQL parser

$prettier --write schema.graphql --parser=graphql

Format a config file without an extension using the JSON parser

$prettier --write .prettierrc --parser=json

Format a file explicitly using the YAML parser

$prettier --write config.yaml --parser=yaml

Configuration

Format files using a specific Prettier configuration file

$prettier --write . --config .prettierrc

Format files using a JavaScript Prettier configuration file

$prettier --write . --config prettier.config.js

Format files ignoring any discovered configuration files

$prettier --write . --no-config

Prefer config file options over CLI options when both are present

$prettier --write . --config-precedence=prefer-file

Let CLI options override config file options when both are present

$prettier --write . --config-precedence=cli-override

Let config file options override CLI options entirely

$prettier --write . --config-precedence=file-override

Print the path to the configuration file resolved for a given file

$prettier --find-config-path src/index.ts

Apply options from .editorconfig when formatting files

$prettier --write . --editorconfig

Ignore .editorconfig settings when formatting files

$prettier --write . --no-editorconfig

Format files using a specific Prettier plugin

$prettier --write . --plugin=prettier-plugin-tailwindcss

Format files using the Prettier PHP plugin

$prettier --write . --plugin=@prettier/plugin-php

Format files using the Prettier Svelte plugin

$prettier --write . --plugin=prettier-plugin-svelte

Info & Debugging

Display the currently installed version of Prettier

$prettier --version

Display help information and all available CLI options

$prettier --help

Print a list of all languages and file types Prettier supports

$prettier --support-info

Print supported languages and file types as JSON

$prettier --support-info --json

Show the parser and config that Prettier would use for a given file

$prettier --file-info src/index.ts

Show file info for a given file in JSON format

$prettier --file-info src/index.ts --json

Show file info using a specific ignore file

$prettier --file-info src/index.ts --ignore-path .prettierignore

Check formatting with verbose debug output for troubleshooting

$prettier --check . --log-level=debug

CI & Integration

Check formatting in CI using .gitignore as the ignore source

$prettier --check . --ignore-path .gitignore

Check formatting of source files in CI showing only warnings and errors

$prettier --check "src/**/*.{ts,tsx,js,jsx}" --log-level=warn

Format all files in CI skipping unknown types and reducing noise

$prettier --write . --ignore-unknown --log-level=warn

Check formatting without failing if a glob pattern matches no files

$prettier --check . --no-error-on-unmatched-pattern

Format all common file types in CI using gitignore and minimal logging

$prettier --write "**/*.{ts,tsx,js,jsx,json,css,md}" --ignore-path .gitignore --log-level=warn