LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

prettier

Opinionated multi-language code formatter

TLDR

Format a file
$ prettier --write [file.js]
copy
Format multiple files
$ prettier --write "[**/*.js]"
copy
Check formatting
$ prettier --check [file.js]
copy
Format with specific parser
$ prettier --parser [typescript] [file]
copy
List files that differ from Prettier formatting
$ prettier --list-different "[**/*.js]"
copy
Format with no semicolons and single quotes
$ prettier --write --no-semi --single-quote [file.js]
copy

SYNOPSIS

prettier [options] [files]

DESCRIPTION

prettier is an opinionated code formatter that enforces a consistent style by parsing code and reprinting it with its own rules. It supports JavaScript, TypeScript, CSS, HTML, JSON, Markdown, YAML, GraphQL, and many other languages through plugins.The tool deliberately limits configuration options to minimize style debates in teams. Files can be formatted in place with --write or checked for conformance with --check, making it suitable for both local development and CI pipelines.

PARAMETERS

FILES

Files to format.
--write
Edit files in place.
--check
Check if formatted.
--parser NAME
Force parser.
--config FILE
Config file path.
--single-quote
Use single quotes.
--tab-width N
Spaces per indentation level (default: 2).
--print-width N
Line length to wrap at (default: 80).
--trailing-comma MODE
Trailing commas: all, es5, or none (default: all).
--no-semi
Do not print semicolons.
--use-tabs
Indent with tabs instead of spaces.
--list-different, -l
Print filenames of files that differ from formatting.
--no-config
Do not look for a configuration file.
--ignore-unknown, -u
Ignore unknown files matched by patterns.
--prose-wrap MODE
Wrapping in markdown: always, never, or preserve (default: preserve).

CONFIGURATION

.prettierrc (or .prettierrc.json, .prettierrc.yaml, prettier.config.js)

Project configuration file defining formatting options like tab width, semicolons, quote style, trailing commas, and print width. Searched upward from the formatted file.
.prettierignore
Glob patterns for files and directories that Prettier should skip, similar to .gitignore format.

CAVEATS

Requires Node.js. Opinionated with deliberately limited configuration options to minimize style debates. Ignores files in node_modules by default.

HISTORY

Prettier was created by James Long in 2017 for consistent code formatting across projects.

SEE ALSO

eslint(1), biome(1)

Copied to clipboard
Kai